Forum: Ruby on Rails contact us form (n00b)

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
F42c010a43e736d18c7f6b846cafc009?d=identicon&s=25 bhanson@hcinsight.com (Guest)
on 2009-05-13 09: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 %>
  <div>
    <%= label :contact, :first_name, "First Name" %><br />
    <%= text_field :contact, :first_name %>
  </div>
  <div>
    <%= label :contact, :last_name, "Last Name" %><br />
    <%= text_field :contact, :last_name %>
  </div>

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

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

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

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


and i have a contacts_controller with the following

class ContactsController < ApplicationController

  def index

  end

  def contacts_mailer
      ApplicationMailer.deliver_contact_mailer(params[:contact])
      flash[:notice] = "Your Message has been sent."
      redirect_to home_path
  end

end

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"
  map.contact 'contact-us', :controller => "contacts", :action =>
"index"

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

thanks

Bob
This topic is locked and can not be replied to.