我在 new.erb.html 中有这样的代码:
<% 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 什么也没产生!为什么!?
导轨:2.3.8
自动完成插件:repeat_auto_complete