No release in over 3 years
Low commit activity in last 3 years
Add a model into another model with an external database connection.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

>= 0
>= 0
~> 5.2.3
 Project Readme

SynchronizedModels

Add a model into another model with an external database connection.

Build Status Coverage Status

Installation

Add this line to your application's Gemfile:

gem 'synchronized_models'

And then execute:

$ bundle install

In the root directory:

$ rails generate synchronized_models_initializer

Usage

Set the values of the external database in the configuration file that was created in config/initializers/synchronized_models.rb by rails generate synchronized_models_initializer command.

Example:

class Account < ActiveRecord::Base
  sync_remote_model model_name: :account
end

# Then:

Account::RemoteAccount.last
Account::RemoteAccount.create name: "Some name"

Or:

class Account < ActiveRecord::Base
  sync_remote_model model_name: :user
end

# Then:

Account::RemoteUser.last
Account::RemoteUser.create email: user@example.com, password: 123456

Or:

class Account < ActiveRecord::Base
  sync_remote_model model_name: :user, table_name: :admins
end

# Then:

Account::RemoteUser.last
Account::RemoteUser.create email: user@example.com, password: 123456

Contributing

Bug report or pull request are welcome.

Make a pull request:

  • Clone the repo
  • Create your feature branch
  • Commit your changes
  • Push the branch
  • Create new Pull-Request

Please write tests if necessary.

License

The gem is available as open source under the terms of the MIT License.