我有:
config/routes.rb
map.resources :projects do |project|
project.resource :privacy
end
end
models/project.rb
belongs_to :privacy
has_one :project
这给了我以下错误:
= change_privacy_button(@project)
错误发生在:
def change_privacy_button(project)
button_builder("24gray/edit.png", "Edit Privacy Settings", edit_project_privacy_path(project), "change_privacy_settings")
end
Rake路线告诉我使用:
Couldn't find Privacy without an ID (ActiveRecord::RecordNotFound)
在调试器中,我可以召唤:
http://localhost:3000/projects/:id/privacy/edit
你的想法?谢谢! PS,以下所有都失败了:
edit_project_privacy GET
/projects/:project_id/privacy/edit(.:format)
{:action=>"edit", :controller=>"privacies"}
答案 0 :(得分:0)
你试过了吗?
edit_project_privacy_path(:project_id => project.id)
或
edit_project_privacy_path(project.privacy, project)
答案 1 :(得分:0)
我猜你的视图中没有设置@project,并且默认为nil。
实例变量将自己初始化为nil,而不是报告它们从未被设置过。
你的ActiveResource或ApplicationController子类叫做什么?