On Apr 15, 2009, at 10:09 AM, Nicktabs wrote:

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

@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

--~--~---------~--~----~------------~-------~--~----~
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 rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to