# Showing the category which belongs to a recipe

**URL:** <https://www.ruby-forum.com/t/showing-the-category-which-belongs-to-a-recipe/128943>\
**Category:** Rails\
**Created:** [February 12, 2008, 9:31pm UTC](https://www.ruby-forum.com/t/showing-the-category-which-belongs-to-a-recipe/128943 "2008-02-12T21:31:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Thufir](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ee7513/32.png) [@Thufir](https://www.ruby-forum.com/u/Thufir)\
**Post date:** [February 12, 2008, 9:31pm UTC](https://www.ruby-forum.com/t/showing-the-category-which-belongs-to-a-recipe/128943/1 "2008-02-12T21:31:58Z")

</div>

I want to do something in the spirit of:

?\> c=Category.find\_by\_id(1)  
=\> #\<Category:0xb70bdee0 @attributes={“name”=\>“food”, “id”=\>“1”}\>

> > c.inspect  
> > =\> "#\<Category:0xb70bdee0 @attributes={“name”=\>“food”,  
> > “id”=\>“1”}  
> > "

Just to kick out all the @category instance fields, but from the show  
view of recipes, which belongs to a category.

So, from the recipes controller I’m fairly confident that I have “this”  
category instance, it’s just a matter of putting in what the views/  
categories/show.rhtml does into views/recipes/show.rhtml to know which  
category a recipe belongs to.

thanks,

Thufir
