Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Rails Engines might be a good fit for this. You can create a Rails Engine gem and add all of your models and rake tasks to consume the data. Then you can include this gem in any app that uses it and also create an API app which includes the gem. You should be able to create observers in your other apps that interact with the gem. </p> <p>I have quite a few apps that interact with each other and this approach works well for me. I have one <em>central</em> app that includes all the engines that consume data and I run all of my cronjobs from this app. I use the <code>use_db</code> plugin which allows my app to communicate with different databases. Each engine has <code>use_db</code> as a dependency and I keep the database configuration inside the gem. One example:</p> <ol> <li>Engine Gem = transaction_core</li> <li>This gem consumes transaction data from a source and inserts it into my transaction database.</li> <li>The gem is included in my <em>central</em> app and I pull the transaction data using a rake task on the cron</li> <li>I include this gem in several other apps that need to use the transaction data. Since the engine automatically adds the models and database config to the app, there is no additional work required to use the models in the app.</li> </ol> <p>I have not used observers inside an app that includes my engines, but I see no reason why it would not work. With the engine the models work as if they are in your app/models directory. Hope this helps!</p> <p>Modest Rubyist has a good 4 part tutorial on Rails 3 plugins that includes Engines:<br> <a href="http://www.themodestrubyist.com/2010/03/05/rails-3-plugins---part-2---writing-an-engine/" rel="nofollow">http://www.themodestrubyist.com/2010/03/05/rails-3-plugins---part-2---writing-an-engine/</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload