I am currently very confused by using descendants
for ActiveRecord::Base-Objects.
I have browsed the internet and tested all solutions but none of them fits my needs.
What i want to do: Get an Array of all subclasses of ActiveRecord::Base, including subclasses of these subclasses, e.g.
Entity < ActiveRecord::Base
ChildEntity < Entity
Property < ActiveRecord::Base
My current problems: ActiveRecord::Base.descendants does NOT list all the classes inheriting from ActiveRecord::Base. Perhaps the fault is on my side: here my code.
def all_entities
rec_all_entities(ActiveRecord::Base)
end
def rec_all_entities(motherEntity)
logger.debug("mother: " + motherEntity.to_s + " descendants: " + motherEntity.descendants.to_s)
motherEntity.descendants.each do |childEntity|
rec_all_entities(childEntity)
end
end
For debbuging purpose I'm just printing out. I'm using Rails 3.
I think the fault must lie in my code. I'm calling the method currently just in the view with <% all_entities %>
Thanks for your help.