title: Mail_form : "No Route Matches [POST]" - Routing Error
body: <p><strong>Rails 3.2</strong></p>
  
  <p>I use the <strong>Mail_form gem</strong> (from plataformatec) to create a simple 'contact us' form for my website. When click on 'send' I get a routing error that says:</p>
  
  <pre><code>Routing Error
  No route matches [POST] "/contactus"
  Try running rake routes for more information on available routes.
  </code></pre>
  
  <p>I have a very simple setup, but I am new to Rails and am still getting the hang of it. I only want the form to send an email to a certain email address... nothing else. I understand the problem is in routes.rb but I have been fiddling with this for so long I just can't figure out what is wrong. I have never struggled with a Rails error so much. PLEASE HELP!</p>
  
  <p><strong>'Pages' Model: app/models/pages.rb</strong></p>
  
  <pre><code>class Page &lt; MailForm::Base
    attribute :name,          :validate =&gt; true
    attribute :email,         :validate =&gt; /\A([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,})\z/i
    attribute :page_title,    :validate =&gt; true
    attribute :page_body,     :validate =&gt; true
  
    def headers
      :subject =&gt; "#{page_title}",
      :to =&gt; "careers@example.com",
      :from =&gt; %("#{name}" &lt;#{email}&gt;)
    end
  end
  </code></pre>
  
  <p><strong>'Pages' Controller: app/controllers/pages_controller.rb</strong></p>
  
  <pre><code>class PagesController &lt; ApplicationController
      respond_to :html
  
      def index
      end
  
      def create
          page = Page.new(params[:contact_form])
          if page.deliver
            redirect_to contactus_path, :notice =&gt; 'Email has been sent.'
          else
            redirect_to contactus_path, :notice =&gt; 'Email could not be sent.'
          end
      end
  end
  </code></pre>
  
  <p><strong>Form Partial: app/views/pages/_form.html.erb</strong></p>
  
  <pre><code>&lt;%= simple_form_for :contact_form, url: contactus_path, method: :post do |f| %&gt;
  
  &lt;div&gt;
      &lt;%= f.input :name %&gt;
      &lt;%= f.input :email, label: 'Email address' %&gt;
      &lt;%= f.input :page_title, label: 'Title' %&gt;
      &lt;%= f.input :page_body, label: 'Your message', as: :text %&gt;
  &lt;/div&gt;
  
  &lt;div class="form-actions"&gt;
      &lt;%= f.button :submit, label: 'Send', as: :text %&gt;
  &lt;/div&gt;
  </code></pre>
  
  
  
  <p><strong>View (called contactus): app/views/pages/contactus.html.erb</strong></p>
  
  <pre><code>&lt;body&gt;
      &lt;div&gt;
          &lt;h2 class="centeralign text-info"&gt;Contact Us&lt;/h2&gt;
      &lt;/div&gt;
      &lt;div class="container centeralign"&gt;
              &lt;%= render 'form' %&gt;
      &lt;/div&gt;
              &lt;h2&gt;We'd love to hear from you! &lt;/h2&gt;&lt;br /&gt;&lt;h4 class="muted"&gt;Send us a message and we'll get back to you as soon as possible&lt;/h4&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p><strong>Routes.rb</strong></p>
  
  <pre><code>Example::Application.routes.draw do
    resources :pages
    root to: 'pages#index', as: :home
    get 'contactus', to: 'pages#contactus', as: :contactus
    get 'services', to: 'pages#services', as: :services
  </code></pre>