title: Rails 3 - form_for pluralization causing path/method error on "new" action but not on "edit"
body: <p>When I go to the path:  <code>/genre/new</code> in my application I get this error:</p>
  
  <pre><code>myapp/app/views/genre/_form.html.erb where line #1 raised:
  undefined method `genres_path' for #&lt;#&lt;Class:0x007fdcb39edcb0&gt;:0x007fdcb39e8080&gt;
  </code></pre>
  
  <p>However when I go to /genre/:id/edit the _form.html.erb file renders without error and the record is updated with no problems.</p>
  
  <p>My <code>new.html.erb</code> and <code>edit.html.erb</code> files call <code>&lt;%= render 'form' %&gt;</code> and my <code>_form.html.erb</code> file has:</p>
  
  <pre><code>&lt;%= form_for(@genre) do |f| %&gt;
      &lt;%= f.label :title %&gt; &lt;br /&gt;  &lt;%= f.text_field :title %&gt;
      &lt;%= f.label :desc %&gt;  &lt;br /&gt;  &lt;%= f.text_field :desc %&gt;
      &lt;%= f.submit %&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>In genre_controller.rb my 'new' and 'edit' actions are as follows:</p>
  
  <pre><code>  def new
      @genre = Genre.new
      current_user.authorize! :create, @genre  # cancan authorization
  
      respond_to do |format|
        format.html # new.html.erb
        format.json { render json: @genre }
      end
    end
  
    def edit
      @genre = Genre.find(params[:id])
      current_user.authorize! :update, @genre   # cancan authorization
    end
  </code></pre>
  
  <p>I've run a search in my codebase for the string "genres" and the only place it occurs is in the logs, so I'm sure this is not a typo in my code.</p>
  
  <p>My guess is that Rails routing system correctly pluralizes "genre" to "genre", but form_for (or a dependency) is creating the pluralization "genres", but only when the parameter passed to it is empty or "new".</p>
  
  <p>Given the error is around 'genres_path', I tried various combinations of the following in my routes.rb file, but they didn't solve the problem:</p>
  
  <pre><code>  match "/genres" =&gt; "genre#index", :as =&gt; :genre
    match "/genres/:id(.:format)" =&gt; "genre#show", :as =&gt; :genre
    match "/genre" =&gt; "genre#index", :as =&gt; :genres
    match "/genre/:id(.:format)" =&gt; "genre#show", :as =&gt; :genres
  </code></pre>
  
  <p>Any thoughts on how I can work around this?</p>
  
  <p>EDIT: Here are the routes generated by the <code>resources :genre</code> statement in my <code>routes.rb</code> file:</p>
  
  <pre><code>genre_index GET    /genre(.:format)           {:action=&gt;"index", :controller=&gt;"genre"}
              POST   /genre(.:format)           {:action=&gt;"create", :controller=&gt;"genre"}
    new_genre GET    /genre/new(.:format)       {:action=&gt;"new", :controller=&gt;"genre"}
   edit_genre GET    /genre/:id/edit(.:format)  {:action=&gt;"edit", :controller=&gt;"genre"}
        genre GET    /genre/:id(.:format)       {:action=&gt;"show", :controller=&gt;"genre"}
              PUT    /genre/:id(.:format)       {:action=&gt;"update", :controller=&gt;"genre"}
              DELETE /genre/:id(.:format)       {:action=&gt;"destroy", :controller=&gt;"genre"}
  </code></pre>