Simple plugin to track changes in associations. Fully working, with proper specs to prove it, tested under Rails 2.1, 2.2 and 2.3
Ruby
Pull request Compare This branch is 2 commits ahead, 2 commits behind openhood:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
lib
spec
.gitignore
MIT-LICENSE
README.textile
Rakefile
init.rb

README.textile

Dirty Associations

Simple plugin to track changes in associations. Fully working, with proper specs to prove it, tested under Rails 2.1, 2.2 and 2.3

Example

class MommyChicken < ActiveRecord::Base has_many :little_chickens dirty_associations :little_chickens end class LittleChicken < ActiveRecord::Base end

and then you can do:

@mommy = MommyChicken.create(:name => “Gertrude”) @mommy.little_chickens.build(:name => “Junior”) @mommy.little_chickens_changed? → true @mommy.little_chickens_was → []

Does now also mixin with ActiveRecord::Dirty to override changed, changed?, changes, and reload_with_dirty.

Enjoy!