Enumerating all models

Hi,

Does anybody know how to enumerate all models (from a controller) ?

Thanks

You could try something like

Dir[RAILS_ROOT + ‘/app/models/*.rb’].each { |file| require file }

This ensures that all models are loaded. Then you should be able to
use something like.

models = ActiveRecord::Base.send(subclasses)
models.each {}

Note, this is untested and therefore may not work.

Chris

Chris R. wrote:

You could try something like

Dir[RAILS_ROOT + ‘/app/models/*.rb’].each { |file| require file }

This ensures that all models are loaded. Then you should be able to
use something like.

models = ActiveRecord::Base.send(subclasses)
models.each {}

Note, this is untested and therefore may not work.

Chris

This is what I was doing, but I thought there is also a way from
ActiveRecord::Base