# Newbie Model Question

**URL:** <https://www.ruby-forum.com/t/newbie-model-question/165623>\
**Category:** Rails\
**Created:** [April 15, 2009, 8:31pm UTC](https://www.ruby-forum.com/t/newbie-model-question/165623 "2009-04-15T20:31:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nicktabs](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/ba9def/32.png) [@Nicktabs](https://www.ruby-forum.com/u/Nicktabs)\
**Post date:** [April 15, 2009, 8:31pm UTC](https://www.ruby-forum.com/t/newbie-model-question/165623/1 "2009-04-15T20:31:39Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Nicktabs](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/ba9def/32.png) [@Nicktabs](https://www.ruby-forum.com/u/Nicktabs)\
**Post date:** [April 15, 2009, 9:03pm UTC](https://www.ruby-forum.com/t/newbie-model-question/165623/2 "2009-04-15T21:03:24Z")

</div>

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
