For some reason the conventional path names for a particular controller are not working? (Rails 3.1)
I created a controller using ryan bates nifty scaffold. Just a controller, no underlying model.
in the controller I have
class ProjectTemplatesController < ApplicationController
# a bunch of stuff
def new
@project = Project.new
end
#more stuff
end
in my view (app/views/project_templates/index.html.erb) I have:
<p><%= link_to "New Project Templates", new_project_templates_path %></p>
however I get the error
undefined local variable or method `new_project_templates_path' for #<#<Class:0x2ab9c24>:0x2ab80e0>
in my routes.rb file I declared the controller as a resource like all the others
resources :project_templates
If I change the link to use
<%= link_to "New Project Templates", {:controller=>"project_templates, :action=>"new"} %>
then it works perfectly?! Why doesnt the naming convension of action_controller_path work in this case?
You can find all of the routes and their names on the command line with
rake routes.Rails knows about the pluralization you are using so it could be magically removing it and naming the route
new_project_template_pathwithout the ‘s’?