Newbie Model Question

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