MaD wrote:
> # controller:
> def show_all_models
> # require all of your models so they get loaded
> Dir.glob(RAILS_ROOT + '/app/models/*.rb').each { |file| require
> file }
> # find all subclasses of ActiveRecord
> @all_models = Object.subclasses_of(ActiveRecord::Base)
> end
>
> # view:
> <ul>
> <% @all_models.each do |model| %>
> <li><%= model %></li>
> <% end %>
> </ul>
>
> if you are using ActiveRecordStore there is probably a model in there
> for that as well. if you don't want to display that one, remove it
> inside your controller.
OK , it works .. but I have to put it inside the animals controller and
inside
the def index , how can I create an "homepage" ?
NEXT STEP
In my app there is a class CAR name:string power:string (has_many:
WHEELS)
... is possible to create a scaffold of MUSCLE_CAR that extend CAR and
inherit everything from CAR (name,power and WHEELS)
and later if I add something to CAR (like door_number) will also appear
into MUSCLE_CAR ?
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---