0

I would like to have two different applications:

  1. Rails application
  2. Process that imports lots of data into the database (same db as used by rails)

The two components are completely independent apart from using the same database and active record models. They would probably be running on different machines.

It doesn't make sense to load the whole rails application every time I want to import data and vice versa.

How do I have two separate applications using the same set of models?

Do I need to have my models separated as an external dependency from both the rails app and the imports process? If so, what's the best way to do that?

I'm aware of delayed_job and the like. However, they seem to be more for executing web application related jobs like batch uploads or emails.

EDIT: More details about the apps: the import process parses statistical data such as series, observations etc. and saves respective models into the database. The web app is dealing with displaying that data and other web stuff like user management, emails etc. I would like to be able to kick off the import process from terminal.

vrepsys
  • 2,143
  • 4
  • 25
  • 37
  • http://stackoverflow.com/a/10870997/184184 – Raj Jan 21 '14 at 14:02
  • 1
    I would question whether or not this is a good approach to solve your problem. Why does your 'Process that imports lots of data into the database' need to know the models used by your Rails application? (It may, indeed need to know them, but it is not clear by the post and the requested method is not a typical rails work-flow, so you may be causing yourself more difficulty than necessary.) – Ecnalyr Jan 21 '14 at 14:11
  • I added more details to the post, hope that answers your question. – vrepsys Jan 21 '14 at 14:21
  • 3
    If the import process is coupled to your rails app's models, it would make more sense to me to call the import process from a rake task in your app, and load the environment that way. That's how we do it and our import scripts live in `/lib/imports`. – Mike Campbell Jan 21 '14 at 14:34
  • Thx for advice. I'm going with the rake task approach -- seems to be the easiest thing to do in this case. – vrepsys Jan 21 '14 at 20:50

0 Answers0