Topic: Retrieve list of all models in your app?
I've finally gotten round to experimenting with rake tasks. What i'd like to do in the one i'm hacking up, is retrieve an array of all the models in my application, and then run a particular method on a subset of those (to be precise, i want to run that method for the models who have a corresponding .yml file in the db directory)
This meta-programming territory is quite unfamiliar to me, is there a way to get an array of all application models within a rake task?
Here's the pseudo code i have so far
desc "Synchronise development and test databases with latest data from svn"
task :sync_db => ["db:migrate","load_data_from_ar_dumps","db:test:clone"]
task :load_data_from_ar_dumps => :environment do
# Get all models in the app and put them in 'models' array
# models.each |m|
# if ... (check if theres a corresponding .yml file in db)
Last edited by cbit (2006-12-05 07:32:05)