On 6 May 2011, at 15:44, Alexey Muranov <[email protected]> wrote:

> Bill, i see no theoretical difficulty in implementing what i want, i was
> just wondering why it is not implemented in Rails (whether it is
> considered a "bad style" for some reason).
> 
> The same way as one does
> 
>  class Payment < ActiveRecord::Base
>    belongs_to :purchase, :polymorphic => true
>  end
> 
> (and then one can use payment.purchase regardless of the type of
> purchase)
> it would be natural to expect that
> 
>  class Payment < ActiveRecord::Base
>    has_one :purchase, :polymorphic => true
>  end
> 
> also be possible, the difference is in storing the foreign key on the
> other side.


How would activerecord know what tables to look at? 

Fred

> Maybe it is considered redundant because one can do
> 
>  class Payment < ActiveRecord::Base
>    has_one :ticket_purchase
>    has_one :membership_purchase
>  end
> 
> but this way one has to first look up  payment.purchase_type,  and then
> use either  payment.ticket_purchase  or  payment.membership_purchase
> accordingly.
> 
> Best regards,
> 
> Alexey.
> 
> -- 
> Posted via http://www.ruby-forum.com/.
> 
> -- 
> 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.
> 

-- 
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.

Reply via email to