I haven't found an exact statement of this problem yet, but if you find one 
please direct me accordingly.

My one problem with polymorphic associations is that your code is now in 
the database. What happens when you rename a class, or re-scope it's module?

Since class name changes are much more common than table name changes 
(citation needed), or at the very least you're not in the DB layer of the 
world and may perhaps not think of it (whereas the inverse may be true), I 
think it makes sense to add an option to reference the polymorphic 
relationship by table.

E.g.

polymorphable_id
polymorphable_table # or polymorphable_table_name

I haven't looked into how one would retrieve the class name from the table, 
but based on this SO post 
<https://stackoverflow.com/questions/20438985/how-to-find-a-model-class-from-its-table-name>
 one 
would have to find a way to perhaps cache the model to table name. Models 
are all loaded anyway, so we could create a reverse-lookup.

Even with thousands of models, I don't think this is unreasonable for the 
convenience, but I'm open to being wrong.

Thoughts?

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/98b782e7-2881-4cf3-80cd-6c5e905ce7b5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to