由于某些原因,某个特定控制器的传统路径名称不起作用? (Rails 3.1)Rails路由名称约定
我使用ryan bates漂亮的脚手架创建了一个控制器。只是一个控制器,没有底层模型。
控制器我
class ProjectTemplatesController < ApplicationController
# a bunch of stuff
def new
@project = Project.new
end
#more stuff
end
在我的视图(app /视图/ project_templates/index.html.erb)我有:
<p><%= link_to "New Project Templates", new_project_templates_path %></p>
但我得到的错误
undefined local variable or method `new_project_templates_path' for #<#<Class:0x2ab9c24>:0x2ab80e0>
在我routes.rb文件我宣布控制器像所有其他的资源
resources :project_templates
如果我更改链接使用
<%= link_to "New Project Templates", {:controller=>"project_templates, :action=>"new"} %>
然后它完美?为什么在这种情况下action_controller_path的命名转换不起作用?
new_project_template_path有效吗?如果是这样,那将是由于变形库 –
您是否已经运行'rake routes',检查路线是否存在,就像您认为的那样? – polarblau