Forum: Ruby on Rails Newbie Model Question

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
3b6b65232c459bfb8ebadb91927b1e9f?d=identicon&s=25 Nicktabs (Guest)
on 2009-04-15 20:31
(Received via mailing list)
I'm building a shop in rails as a learning excercise. I've got to the
last part when I'm sending out e-mail order confirmations. The e-mails
contain a list of each line item the customer ordered, I also want to
display the catgory name the customer ordered from.

The database is setup: Category > Product > Line_item.
So I want to navigate back from line_item > product > category so i
can display the category name in the email however im not sure how I
tell it to find the category name from the item.

Be greatful for anyhelp.
2505b282d57c29be797dc35b245adb4c?d=identicon&s=25 Philip Hallstrom (Guest)
on 2009-04-15 21:03
(Received via mailing list)
On Apr 15, 2009, at 10:09 AM, Nicktabs wrote:

>
> Be greatful for anyhelp.

@line_item.product.category.name

Assuming all the associations are setup correctly.

You can also set it up using :through so that you can just to
@line_item.category.name

-philip
This topic is locked and can not be replied to.