【发布时间】:2010-06-26 15:12:05
【问题描述】:
我在 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
自动完成插件:repeated_auto_complete
【问题讨论】:
-
我已经编辑了我的答案...
标签: ruby-on-rails nested-forms nested-attributes fields-for