Ruby 关于两个表单之间字段调用问题,求指点

lengcb · October 21, 2015 · Last by lengcb replied at October 21, 2015 · 1307 hits

这里有两个表单,一个父表(teams),一个子表(users)(新手,名称说法上有问题请指出),team.rb 中 has_many :users, user.rb 中 belongs_to :team 我知道 team 中调用 user 表中的字段,用 accepts_nested_attributes_for :users。单反过来,user 中调用 team 的字段就不会了,请各位高手指点

accepts_nested_attributes_for :team, 在创建 user 的表单里面,f.fields_for :team, @user.team || Team.new do |f1|, 试试看行不行

#1 楼 @leomayleomay ok,可以,解决了

You need to Sign in before reply, if you don't have an account, please Sign up first.