Dynamord
TODO: Write a gem description
Installation
Add this line to your application's Gemfile:
gem 'dynamord'
And then execute:
$ bundle
Or install it yourself as:
$ gem install dynamord
Usage
Install the intializer configuration files
$ rails g dynamord:install
Add Dynamord to your models (both Active record and dynamoid)
class User < ActiveRecord::Base
include Dynamord
end
and dynamoid:
class Picture
include Dynamoid::Document
include Dynamord
end
on the dynamoid side you can use:
- to_active_record_belongs_to
- to_active_record_has_many
- to_active_record_has_one
and on the ActiveRecord side
- from_active_record_belongs_to
- from_active_record_has_many
- from_active_record_has_one
you'll need to specify the association class and sometimes the foreign key (in has_*
associations)
class Picture
include Dynamoid::Document
include Dynamord
to_active_record_belongs_to :user, :class => User
end
class User < ActiveRecord::Base
include Dynamord
from_active_record_has_many :pictures, :class => Picture, :foreign_key => "user_id"
end
Also add the association in your ActiveRecord migration file
class CreateOrganisations < ActiveRecord::Migration[5.1]
def change
create_table :organisations do |t|
t.string :name
t.string :url
t.from_active_record_belongs_to :industry
t.timestamps
end
end
end
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request