Topic: How to find out what a model has_many of?
I'm trying to write a view partial that can be passed an unknown model object, and can list all of its 'primitive' attributes (like scaffolding does), but that can also list all its associations. I'm trying to figure out how I can get the classnames of all the models that the target model has_many of. In other words, given the following:
class User < ActiveRecord::Base
Is there any good way to get @some_user to return something like '[widgets, thingies]'?
Right now I'm thinking I'd have to extend ActiveRecord::Associations to maintain an array of strings and a reader method, and to add to it when the has_many method gets called. Is this a bad idea or a waste of time? Thanks for any help!