I have
class CarpoolGroup < ActiveRecord::Base
has_many :cars
end
class Car < ActiveRecord::Base
belongs_to :carpool_group
has_many :car_types
end
class CarType < ActiveRecord::Base
has_one :carpool_group, through: :car
end
When I set
cat_type.carpool_group = nil
or when I save the carpool_group, the joined Car object got deleted from the DB. I see the SQL DELETE from "cars" where ... after I set car_type.carpool_group = nil
.
How do I keep the has_one through association and avoid this deletion?
Aucun commentaire:
Enregistrer un commentaire