Skip to content

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

License

Notifications You must be signed in to change notification settings

monsterlabs/move_associations

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages