rails 3 habtm delete only association

后端 未结 3 671
伪装坚强ぢ
伪装坚强ぢ 2020-12-31 02:08
class Company
  has_and_belongs_to_many :users
end

class User
  has_and_belongs_to_many :companies
end

when i delete a company, what\'s the best (

3条回答
  •  太阳男子
    2020-12-31 02:31

    http://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html#method-i-has_and_belongs_to_many

    collection.delete will do the trick.

提交回复
热议问题