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
2010-07-06 20:46:30
I am talking about regularly recurring jobs that load fresh data into the DB from an external data provider.
tesmar
2010-07-06 21:22:05
+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
2010-07-06 20:56:02
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
2010-07-07 03:20:53
Yeah - I'd put them in tasks/, then you can call rake from cron to load your data
RyanWilcox
2010-07-07 11:14:39
A:
rake db:seed
would be the best imo
put your script in db/seeds.rb
Omar Qureshi
2010-07-06 21:04:00