jeudi 16 avril 2015

My rendered partial '_form' appears, but is not submitting

Ruby 2.1.5 on Rails 4.2.0:


I have two directories. One directory is a rails-generate scaffold named 'inqueries'. The other directory is named 'welcome', which only houses a landing paged named index.html.erb. The inquery form works & submits fine as long as I'm using the view from the actual 'inquery' scaffold/directory.


I am able to render the inquery _form on my index.html.erb landing page using :



<%= render partial: "inqueries/form", locals: {inquery: @Inquery} %>


However, this JUST renders the form. When I hit the submit button, no errors, flash messages, or inquery is submitted. It is complete non-action, including on my rails terminal.


How can I properly make the form work on my landing page?


Here is my welcome_controller.rb file. This controller handles the landing page where I am trying to render the inquery scaffold's form:



class WelcomeController < ApplicationController

def index
@inquery = Inquery.new
render layout: false
end
end


This is my new rails scaffold-generated method in the inqueries_controller.rb:



def new
@inquery = Inquery.new
respond_with(@inquery)
end


Sorry, Here is the Inquery _form itself:



<%= form_for(@inquery) do |f| %>
<div class="form-group col-lg-4">
<%= f.label t('.name') %><br>
<%= f.text_field :name, class: "form-control" %>
</div>

<div class="form-group col-lg-4">
<%= f.label t('.email') %><br>
<%= f.text_field :email, class: "form-control" %>
</div>

<div class="form-group col-lg-4">
<%= f.label t('.phone') %><br>
<%= f.text_field :phone, class: "form-control" %>
</div>

<div class="clearfix"></div>
<div class="form-group col-lg-12">
<%= f.label t('.message') %><br>
<%= f.text_area :message, rows: 8, class: "form-control"%>
</div>
<%= f.submit t('.submit'), class: "btn btn-primary" %>
<% end %>


EDIT 2: I saw there were a couple of suggestions with the logic. I have simplified the partial just to see if I could get it to work and it still does not submit properly outside of its directory. I am new to rails, do I need to render a new action in the second directory that I am calling it into?


Aucun commentaire:

Enregistrer un commentaire