我有一个非常简单的模型/视图但由于某种原因我似乎无法访问新的记录变量,因此得到错误:
undefined method `hash_for_checklists_path' for # Module:<0x00000100f8b9b0>
我已经把头靠在墙上几个小时了。谁能看到我做错了什么?
class ChecklistsController < ApplicationController
def new
@title = "New Checklist"
@checklist = Checklist.new
end
[...]
end
(顺便说一下,我的application.html.erb文件获取@title变量没有问题。)
<%= form_for @checklist do |f| -%>
devise_for :users
resources :checklist_item_categories, :as => 'item_categories' do
resources :checklist_items
end
resources :checklist_categories do
resources :checklists
end
match 'checklists/new', :to => 'checklists#new'
#pages
get "pages/home"
get "pages/contact"
#checklist items
get "checklist_items/new"
#checklists
get "checklists/new"
get "checklists/edit"
get "checklists/show"
get "checklists/index"
#categories
get "abstract_categories/new"
答案 0 :(得分:1)
您没有表单中的帖子路径。
也许放
resources :checklists
取代
#checklists
get "checklists/new"
get "checklists/edit"
...