Knowing the parent of an object

An Article could belong_to several models, so you could have
@article.category and @article.magazine. How would @article.parent
know which 'parent' to use?


Colin Law wrote:

I totally agree, but it would be convenient to obtain an array of
multiple parents. Something like:

parents = @article.belongs_to
parents # => ["Magazine", "Category"]

Look into reflections, there should be something in there you can rely