# Find (:all) method

**URL:** <https://www.ruby-forum.com/t/find-all-method/142685>\
**Category:** Rails\
**Created:** [July 10, 2008, 11:17am UTC](https://www.ruby-forum.com/t/find-all-method/142685 "2008-07-10T11:17:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![seb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8edcca/32.png) [@seb](https://www.ruby-forum.com/u/seb)\
**Post date:** [July 10, 2008, 11:17am UTC](https://www.ruby-forum.com/t/find-all-method/142685/1 "2008-07-10T11:17:14Z")

</div>

i have 2 models items and categories…in items listing i have category  
name,title…etc…  
In item edit page i want to display the title of all item having the  
same category name.means when clicking on edit field of one item it  
should show edit details and the title of the items which have the  
same catoegory name.how can i do this …so i think have to use some  
find method or something…then where should i write the code? in item  
controller ?then how can i call it from my listing items ?somebody  
help me pls…

---

<div class="post-metadata">

**Author:** ![seb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8edcca/32.png) [@seb](https://www.ruby-forum.com/u/seb)\
**Post date:** [July 10, 2008, 11:37am UTC](https://www.ruby-forum.com/t/find-all-method/142685/2 "2008-07-10T11:37:24Z")

</div>

If you are using rails 2.1 then you can use a named scope on the Item  
model like such

== in Item  
belongs\_to :category  
named\_scope :same\_category, :include =\> :category, :conditions =\>  
{ ‘category.name’ =\> category.name }  
then you can do

== IteamsController (i suppose)  
def edit  
@iteams = Item.same\_category  
@item = …  
end

and it will do the find for you.

have a look at: [#108 named\_scope - RailsCasts](http://railscasts.com/episodes/108)
