Q:

Organize separate child Models under one namespace

I'm building an app that will allow users to create custom sites using configurable widgets (essentially just child objects of a site). Currently each widget is its own separate model so I have to access them individually through a user's site object such as @site.headers and @site.galleries.
What I would like to do is set up a way to reference these individual child objects under one namespace, Widget, so that I can just use @site.widgets to return a hash of all my individual child objects that belong to a site.
I've looked into something like this below, but I don't think :class_name accepts an array.
has_many :widgets, :foreign_key => 'site_id', :class_name => ['Header', 'Gallery']

A:

It's impossible to define this as an association. instead, you can define your own method:
def widgets
  headers + galleries
end

but remember that the result of this method will be simple Array, not an ActiveRecord::Relation - so you won't be able to call AR scope methods on this. 

