Rails : No route matches , creating contact us form
I am making a contact us form that doens't have any model. I just want it to be a popup in the home page when people click on contact us.
In the partial we load _contact.html.haml , this is what we have
<div class="contact-us-form">
<h>Contact Us</h>
<% form_tag(:controller => "application", :action => "deliver_contact_form", :metho开发者_如何学JAVAd=>'post') do %>
<p>
<%= label_tag(:contact_email, "Your Email") %>
</p>
<p>
<%= text_field_tag(:contact_email) %>
</p>
<p>
<%= label_tag(:contact_detail, "Details") %>
</p>
<p>
<%= text_area_tag(:contact_detail,:"", :size=> "44x6") %>
</p>
<p>
<%= submit_tag("Submit") %>
</p>
<% end %>
<div id="contact_cancel"><%= link_to "Cancel", "javascript:void()"%></div>
</div>
and we define the action deliver_contact_form as this in application_controller.rb
def deliver_contact_form
ContactMailer.welcome_email(params).deliver
respond_to do |format|
format.html { redirect_to comments_path }
end
end
when I run just the home page (localhost:3000) I get
No route matches {:controller=>"application", :action=>"deliver_contact_form", :method=>"post", :locale=>:en}
I was wondering what I need to do?
Thanks, mina
You need to define the route in your routes.rb
I also suggest creating a new controller, even for a small action like this, anyway:
match '/deliver_contact_form' => 'application#deliver_contact_form', :via => :post
<% form_tag(deliver_contact_form_path, :method => 'post') do
精彩评论