Using HABTM or Has_many through with Active Admin

安稳与你 提交于 2019-12-06 00:48:33
James

Did you try to add below lines to your Conference model?

# conference.rb
attr_accessible : conferenceaccounts_attributes
has_many :conferenceaccounts

# This line after your your relations
accepts_nested_attributes_for : conferenceaccounts, :allow_destroy => true

see: accept nested attributes for has_many relationship

When using has_many through: :some_model, make sure to define has_many on :some_model also, for example:

If you have:

class Account < ActiveRecord::Base
  has_many :conferences, :through => :conferenceaccount
end

Transform it into:

class Account < ActiveRecord::Base
  has_many :conferences, :through => :conferenceaccount
  has_many :conferenceaccount                              # <- added
end
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!