Hi Alexey,

On Fri, May 6, 2011 at 6:59 AM, Alexey Muranov <[email protected]> wrote:
> Thanks Bill,
> i am aware of the alternatives, but i was wondering if i can keep this
> database schema which i like for that case, and to still be able to use
>
>  payment = Payment.find(1)
>  puts payment.purchase.inspect
>
> so that payment.purchase was either TicketPurchase or
> MembershipPurchase, while the foreign keys were stored in purchases
> tables.

The problem you're up against is that relational databases don't
support inheritance.  So you'd either need to use:

payment.purchase.membership_purchase.inspect

or move to an STI model for purchases and drop the ticket_purchases
and membership_purchases tables altogether if you want / need to be
able to get any 'meaningful' information from payment.purchase.inspect

Google 'rails sti' for some good links on how Rails implements / supports STI.

Best regards,
Bill

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