Q:

undefined method `premails_path' for #<#:0x52c1ec8>

I am trying to add a pre-launch sign-up email form on my pages index view. I made a form on my view, then created a controller, then made the model and table and ran the migration. Is this the right way to do it?
I am getting the following error:
NoMethodError in Pages#index
undefined method `premails_path' for #<#<Class:0x4fa8530>:0x52c1ec8>

on line:
<%= form_for(@premail) do |f| %>

from 
<%= form_for(@premail) do |f| %>
     <% if @premail.errors.any? %>
       <div id="error_explanation">
         <h2><%= pluralize(@premail.errors.count, "error") %> prohibited this link from being saved:</h2>

My pages controller has the following:
class PagesController < ApplicationController

    def index
      @premail = Premail.new
    end

end

My pages index view has the following:
<%= form_for(@premail) do |f| %>
  <% if @premail.errors.any? %>
    <div id="error_explanation">
      <h2><%= pluralize(@premail.errors.count, "error") %> prohibited this link from being saved:</h2>

      <ul>
      <% @premail.errors.full_messages.each do |msg| %>
        <li><%= msg %></li>
      <% end %>
      </ul>
    </div>
  <% end %>

  <div class="field">
    <%= f.label :Email %><br />
    <%= f.text_field :Email %>
  </div>
  <div class="actions">
    <%= f.submit %>
  </div>
<% end %>

I generated the following model:
class Premail < ActiveRecord::Base

end

and the following db migrate table:
class CreatePremails < ActiveRecord::Migration
  def change
    create_table :premails do |t|

        t.text    :email

      t.timestamps
    end
  end
end

What can I do differently to make this work?

A:

Because you're loading this form on Pages#index, you'll benefit from using the url: argument like this:
<%= form_for @premail, url: pages_index_path do |f| %>

Update
From the Rails guide:

Resource-oriented style
In the examples just shown, although not indicated explicitly, we
  still need to use the :url option in order to specify where the form
  is going to be sent. However, further simplification is possible if
  the record passed to form_for is a resource, i.e. it corresponds to a
  set of RESTful routes, e.g. defined using the resources method in
  config/routes.rb. In this case Rails will simply infer the appropriate
  URL from the record itself. For example,
<%= form_for @post do |f| %>   ... <% end %> is then equivalent to

something like:
<%= form_for @post, as: :post, url: post_path(@post), method: :patch,
html: { class: "edit_post", id: "edit_post_45" } do |f| %>   ... <%
end %>

As you're using @premails instance var (which is an instance of the Premail class), your form_for helper will be trying to use a premails path. To use a pages path (as per your question), you'll need to manually set the url option

