MoveAssociations

This gem extends ActiveRecord to move associated records based on has_many and has_one associations.

Getting started

In your Gemfile:

gem "move_associations"

Example usage

class City
  validates_presence_of :name
  belongs_to :state
  has_many :addresses
  has_one  :person
  has_many :institutions
end

@city = City.find(10)
@city.move_association(:addresses, 15) => # It move the associated records in addresses table from city with ID 10 to city with ID 15.

@city = City.find(10)
@city.move_associations(15)            => # It moves all the associated records from city with ID 10 to city with ID 15 using the 
                                          # has_many and has_one relationships.

Copyright

Copyright © 2010 MonsterLabs. See LICENSE for details.