Associator

Associate any model to any model.

Description

Creates a one-to-many relationship between any models.

Installation

1 Add to your application Gemfile

  gem 'associator'

2 Type

  bundle install
  rake associator_engine:install:migrations
  rake db:migrate

Usage

In your rails app model

Add to your model

  associated :with => :THE_OTHER_MODEL_NAME

or

  associated :with => :RELATION_NAME, :class_name => 'THE_OTHER_MODEL_CLASS_NAME'

Add relation

  foo = Foo.first
  bar = Bar.first
  foo.add_associated bar

Remove relation

  foo = Foo.first
  bar = Bar.first
  foo.del_associated bar

License

Released under the MIT license: http://www.opensource.org/licenses/MIT