So I'm looking at someone's code which has the following (paraphrased):
class user
has_one :connection, :dependent => :destroy
has_one :second_user, :through => :connection, :class_name => 'User'
end
class connection
belongs_to :user
belongs_to :second_user, :class => 'User'
end
If I have a connection object and delete the associated 'user' it can be destroyed fine. But I also want to make it so that if the User occupying the 'second_user' field is destroyed the connection is destroyed. How can I accomplish that pretty seamlessly without messing with too much (hopefully no migrations needed)?
Thanks!