mercredi 15 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 id="error_explanation">
<% if @inquery.errors.any? %>
<h2>
<%= pluralize(@inquery.errors.count, "error") %> prohibited this inquery from being saved:
</h2>
<ul>
<% @inquery.errors.full_messages.each do |message| %>
<li><%= message %></li>
</ul>
<% end %>
</div>
<% end %>
<br />
<form role="form">
<div class="col-lg-12">
<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>
<div class="form-group col-lg-12">
<input type="hidden" name="save" value="contact">
<%= f.submit t('.submit'), class: "btn btn-primary" %>
</div>
</div>
</form>
<% end %>

Aucun commentaire:

Enregistrer un commentaire