views:

29

answers:

3

In your experience, where is the best place to place scripts that run data loading jobs, but which rely on rails? In my project they are in the model folder, but that adds a lot of code to the model folder and won't rails load it all into memory when the server is run (unnecessarily)? The lib/ folder looks good, but those don't have rails access unless you manually specify that in the scripts. Any clean solution here?

A: 

What do you mean by 'data loading jobs'? If they are scripts that manipulate the database, put them in db/.

mckeed
I am talking about regularly recurring jobs that load fresh data into the DB from an external data provider.
tesmar
+2  A: 

Are you talking jobs that you fire off via rake? (then tasks/)

Or are you talking putting data into the Rails app, then maybe you want something like the data_migration plugin.

RyanWilcox
I am talking about a CRON job that calls script/runner to run a method in a load model. It is a regularly recurring job that load fresh data into the DB from an external data provider, should this be moved to rake in order to clear up the models dir?
tesmar
Yeah - I'd put them in tasks/, then you can call rake from cron to load your data
RyanWilcox
A: 

rake db:seed would be the best imo

put your script in db/seeds.rb

Omar Qureshi