class Company
has_and_belongs_to_many :users
end
class User
has_and_belongs_to_many :companies
end
当我删除公司时,最好的(推荐)方法是仅从该公司删除用户的关联? (我的意思不是实际用户,只有关联)
最佳答案
http://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html#method-i-has_and_belongs_to_manycollection.delete
将解决问题。
关于ruby-on-rails - rails 3 habtm只删除关联,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4994245/