Quantcast

IRC question of the day

January 9th, 2009

Question:

_adc: I'm doing compiling some reports on various database records based in whatever
 model the user chooses... Is there a better way to figure out which models are in 
existence than http://pastie.org/356630 ?
_adc: I'm looking for an array of all models currently in existence.

Answer:

ActiveRecord::Base.subclasses_of(ActiveRecord::Base)

~/projects/learnhub$ ./script/console 
Loading development environment (Rails 2.1.1)
>> ActiveRecord::Base.subclasses_of(ActiveRecord::Base).collect {|c| c.to_s }
=> ["CGI::Session::ActiveRecordStore::Session", "ContactPostCreationNotification", .....]

Sorry, comments are closed for this article.