I want to delete all record of group_maps that is associated with the group of it. In the docs, its saying
If the :through option is used, then the join records are destroyed instead, not the objects themselves.
Im confused.
group.rb
class Group < ApplicationRecord
belongs_to :user
has_many :group_maps
has_many :users, :through => :group_maps
before_destroy :destroy_group_maps
def destroy_group_maps
self.group_maps.delete_all
end
end
Aucun commentaire:
Enregistrer un commentaire