Rails models + database updates from outside rails

Hi Folks,

I am newbie to RoR, and I was looking for a way to do the following:

1. Run a service that provides a RESTful API. 2. Use the rails ORM (it is really convenient) 3. Keep the models up to date with data from another source on the system (in addition to updates to the models via rails controllers).

Now, RoR is great for 1 and 2. For 3, I am thinking of writing a daemon, but the daemon needs access to the database (possibly via the Rails ORM). Another constraint is that I am using a JRuby-based system.

Has anybody attempted something like this before? What have you used? Please share your experiences.

Thanks, Radhesh

I am newbie to RoR, and I was looking for a way to do the following:

3. Keep the models up to date with data from another source on the system (in addition to updates to the models via rails controllers).

Now, RoR is great for 1 and 2. For 3, I am thinking of writing a daemon, but the daemon needs access to the database (possibly via the Rails ORM).

You almost certainly want to use the same ORM to access the DB so the same business logic (validations, etc.) is used.

Your use case is pretty vague, but sure, daemon, cron job, whatever works. :slight_smile:

Another constraint is that I am using a JRuby-based system.

Shouldn't matter.

Has anybody attempted something like this before?

No different than using script/runner for one-offs or cron jobs, or the Rails console, etc.

FWIW,

I am newbie to RoR, and I was looking for a way to do the following:

3. Keep the models up to date with data from another source on the system (in addition to updates to the models via rails controllers).

Now, RoR is great for 1 and 2. For 3, I am thinking of writing a daemon, but the daemon needs access to the database (possibly via the Rails ORM).

You almost certainly want to use the same ORM to access the DB so the same business logic (validations, etc.) is used.

Your use case is pretty vague, but sure, daemon, cron job, whatever works. :slight_smile:

So a daemon goes into the lib directory and can be started whenever Rails starts?

Another constraint is that I am using a JRuby-based system.

I heard that the 'daemon' ruby gem works only for MRI and not on JRuby, is that true?

So a daemon goes into the lib directory and can be started whenever Rails starts?

If that's what you want to do, sure.

Another constraint is that I am using a JRuby-based system.

I heard that the 'daemon' ruby gem works only for MRI and not on JRuby, is that true?

Yes, but googling "jruby daemon process" will get you lots of possible alternatives.