处理表单我有一个形式,我的档案编辑观点与此行的开头:与单表继承
<% form_for @profile, :html => { :multipart => true } do |f| %>
资料进行单表继承和两个子类档案::艺术家和个人资料::监听器。
当我尝试访问编辑查看配置文件,我得到这个错误:
NoMethodError in Profiles#edit
Showing /rubyprograms/dreamstill/app/views/profiles/edit.html.erb where line #1 raised:
undefined method `profile_artist_path' for #<#<Class:0x103359a18>:0x1033560c0>
,其中线1的代码,我上面贴在表格的行。我该如何解决这个错误?
UPDATE:
我将此代码添加到我的个人资料型号:
def self.inherited(child)
child.instance_eval do
def model_name
Vehicle.model_name
end
end
super
end
现在我的错误已更改为:
NameError in Profiles#edit
Showing /rubyprograms/dreamstill/app/views/profiles/edit.html.erb where line #1 raised:
uninitialized constant Profile::Vehicle
更新2:
我改变表格的第一行为:
,并提交按钮<%= f.submit :profile %>
现在我只是得到一个路线错误...
'require'vehicle''? – lebreeze 2011-03-28 06:58:52
http://stackoverflow.com/questions/5246767/sti-one-controller/5252136#5252136 – fl00r 2011-03-28 07:00:44
此外,它仍然像一个路由错误:'undefined方法profile_artist_path' – lebreeze 2011-03-28 07:00:49