Well, that's definitely a "complicated" example :) I guess you should try to figure out with the core rails guys where you could hack the code to do just that (what would be infer the name of the real association from something else), i haven't looked at the code myself, but it shouldn't be that hard with the right guidance.
Also, if you want to roll your own solution, it isn't that hard and there's also plenty of work already written about the matter, one of the best options is Martin Fowler's "Patterns of Enterprise Application Architeture" ( http://martinfowler.com/eaaCatalog/index.html ), there are 3 sections about object-relational mapping tool structure. On Wed, Oct 8, 2008 at 1:30 AM, Aryk Grosz <[EMAIL PROTECTED]> wrote: > > Sure Mauricio, here's an example. > > Lets say you have a "products" table. You have product_type table column > in that table that you use for single table inheritance. So lets say you > have the value "book" as the product_type. > > Now you want to have a pricing for this product, so you do: > > belongs_to :pricing, :polymorphic => true > > So now you need a pricing_type with a class name of "BookPricing", or in > other words "#{product_type.classify}Pricing". You will always follow > this convention since I wouldnt have BookPricing for a product_type of > "poster" > > But wait! There's more. Now I want another polymorphic association for > "details" for that product. So I do: > > belongs_to :detail, :polymorphic => true > > So, now I need a "detail_type" column of "BookDetail" or in other words > "#{product_type.classify}Detail". > > Now I have two extra string columns that are not needed and are making > things much less DRY. > > Aryk -- Maurício Linhares http://alinhavado.wordpress.com/ (pt-br) | http://blog.codevader.com/ (en) João Pessoa, PB, +55 83 8867-7208 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---

