title: Detecting changes in a rails has_many :through relationship
body: <p>I have a model that has a number of has_many, and has_many :through model relationships. For example, in my User class I have:</p>
  
  <p>has_many :languages, through: :profile_languages</p>
  
  <p>What I would like is to be able to detect when these are added or removed using the 'User.changes' function, which returns an array of attributes that have been changed when called with the User.language_ids= function.  </p>
  
  <p>Has anyone else tried to do this, or have experience with this?</p>
  
  <p>Info on the ActiveModel changes function: <a href="http://api.rubyonrails.org/classes/ActiveModel/Dirty.html">http://api.rubyonrails.org/classes/ActiveModel/Dirty.html</a></p>
  
  <p>Edit: As requested, here is what I am doing.  </p>
  
  <p>After a user's attributes are assigned and before it is saved, I am looking at all of the values returned from the .changes, in order to log all the changes made in an external log.</p>
  
  <p>So if I call u.name = "new name"</p>
  
  <p>then u.changes returns {name: ['old name', 'new name']}</p>
  
  <p>However, when I pass a user a bunch of language ids, such as</p>
  
  <p>u.language_ids = [4,5]</p>
  
  <p>Then there are a number of ProfileLanguage models created,  and the u.changes hash is left blank.</p>
  
  <p>I am attempting to create some callbacks in the ProfileLanguage model that would manually create some sort of a hash,  but I am wondering if this is indeed the best solution.</p>