我new.erb.html有这样的代码:Ruby on Rails的:如果定义submodel_attributes fields_for无能为力=
<% form_for(@ratification) do |f| %>
<%= f.error_messages %>
<% f.fields_for :user do |fhr| %>
<p>
<%= fhr.label :url %><br />
<%= fhr.text_field_with_auto_complete :url %>
</p>
<% end %>
<% end %>
如果我有空Ratification.rb它是好的,fields_for工程确定。
但如果我写:
class Ratification < ActiveRecord::Base
belongs_to :user
accepts_nested_attributes_for :user
end
或
class Ratification < ActiveRecord::Base
belongs_to :user
def user_attributes=(attr)
...
end
end
f.fields_for产量什么!为什么!?
的Rails:2.3.8
插件自动完成:repeated_auto_complete
我编辑了我的答案... – 2010-06-26 16:18:33