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?
views:
33answers:
1hm... 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?
動靜能量
2010-09-06 15:52:50
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
2010-09-06 20:10:46