The method to walk through apps/models and look into each file for classes is not what I'm looking for
views:
58answers:
1
A:
For example:
Module.constants.select do |constant_name|
constant = eval constant_name
if not constant.nil? and constant.is_a? Class and constant.superclass == ActiveRecord::Base
constant
end
end
Jonas Elfström
2009-12-28 20:05:41
There's no such a way that I asked for among listed in there. Some do work properly, some don't. And no suitable method for my case.
MG
2009-12-28 20:37:16
What's wrong with the example above?
Jonas Elfström
2009-12-28 21:36:27
This method most of all looks like a needed answer. But when I tried it on my project, it returned just a few of its models. I did not dive deep into why that's so.
MG
2009-12-29 19:30:00
It could be that you actually have to instantiate the model and that would be a bummer. Can't test that theory right now.
Jonas Elfström
2009-12-29 22:05:05
This method also returns just a couple of models either from within a console or from within a view. Even more, it returns different sets of models from different views. That means that you're right -- the returned models list depends on context. The question turned out to be not so simple...
MG
2009-12-30 01:16:47