views:

33

answers:

1

which is to find out all the Models in the app. This can be found out from the project folders / filenames, or in the route.rb, but just wonder if there is a Ruby way of finding it out on script/console?

+2  A: 

This has come up before.

http://stackoverflow.com/questions/516579/is-there-a-way-to-get-a-collection-of-all-the-models-in-your-rails-app

jdl
hm... that solution either uses file listing in a folder, or looking for subclasses, but won't show the class until the class is actually used before... so they both don't seem a complete solution... must the file system be touched for Rails to know? In other words, Rails have no knowledge of Models in the app until it actually goes to app/models to load the file?
動靜能量
Yes, because Rails autoloads (i.e. lazily-loads) models in the development environment, the file isn't loaded until its class name is referenced somewhere in executed code. This is not the case in production, though.
John Douthat