Forum: Ruby on Rails contact us form (n00b)

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
on 2009-05-13 11:57
(Received via mailing list)
Im at a loss..and its something with my routes..

i have an index.html.erb that generates a partial

<% page_title("Contact Us") %>

<% content_for :banner do %>
  <%= render :partial => 'contacts/banner' %>
<% end %>

<%= render :partial => 'contacts/form' %>

The partial in the contacts directory _form.html.erb

<% form_tag :action => "contacts_mailer" do %>
    <%= label :contact, :first_name, "First Name" %><br />
    <%= text_field :contact, :first_name %>
    <%= label :contact, :last_name, "Last Name" %><br />
    <%= text_field :contact, :last_name %>

    <%= label :contact, :subject, "Subject" %><br />
    <%= text_field :contact, :subject %>

    <%= label :contact, :body, "Message" %><br />
    <%= text_area :contact, :body, :rows => 10 %>

    <%= label :contact, :email, "Email Address" %><br />
    <%= text_field :contact, :email %>

    <%= submit_tag 'Send Request', :class => "btn" %>
    <%= submit_tag 'Clear Form', :class => 'btn', :type => 'reset' %>
<% end %>

and i have a contacts_controller with the following

class ContactsController < ApplicationController

  def index


  def contacts_mailer
      flash[:notice] = "Your Message has been sent."
      redirect_to home_path


And i have the ApplicationMailer setup according to a dozen tutorials.

the problem comes with the form action.
i have called
<% form_tag :action => "contacts_mailer" do %>
<% form_tag :controller => "contacts", :action => "contacts_mailer" do

and in the source it shows <form method="post" action="/contact-us">

and i do have these in the routes

  map.contact_mailer 'contact-us', :controller => "contacts", :action
=> "contact_mailer" 'contact-us', :controller => "contacts", :action =>

I im getting this error

Showing app/views/contacts/_whistle.html.erb where line #1 raised:

No route matches {:action=>"contacts_mailer"}

ive even created a contacts_mailer.html.erb but no dice.

any help would be awesome


This topic is locked and can not be replied to.