# Def list routing

**URL:** <https://www.ruby-forum.com/t/def-list-routing/141742>\
**Category:** Rails\
**Created:** [June 30, 2008, 9:46am UTC](https://www.ruby-forum.com/t/def-list-routing/141742 "2008-06-30T09:46:53Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![torso](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/34f0e0/32.png) [@torso](https://www.ruby-forum.com/u/torso)\
**Post date:** [June 30, 2008, 9:46am UTC](https://www.ruby-forum.com/t/def-list-routing/141742/1 "2008-06-30T09:46:53Z")

</div>

Hi!

I have made an scaffold for Item table like script/generate scaffold  
Item. Everything went fine, but now i like to add list action to  
controller

Def list  
$items = Item.finde(:all)  
end  
I have added it, but how i can see the template like  
[http://address/items/list](http://address/items/list)

Can i redirect it some how?  
Action index does same thing as list action,but i want to make  
different kind of view for those.

---

<div class="post-metadata">

**Author:** ![torso](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/34f0e0/32.png) [@torso](https://www.ruby-forum.com/u/torso)\
**Post date:** [June 30, 2008, 11:42am UTC](https://www.ruby-forum.com/t/def-list-routing/141742/2 "2008-06-30T11:42:20Z")

</div>

torso wrote:

> Hi!
> 
> I have made an scaffold for Item table like script/generate scaffold  
> Item. Everything went fine, but now i like to add list action to  
> controller
> 
> Def list  
> $items = Item.finde(:all)  
> end  
> I have added it, but how i can see the template like  
> [http://address/items/list](http://address/items/list)
> 
> Can i redirect it some how?  
> Action index does same thing as list action,but i want to make  
> different kind of view for those.

I think you did not declare it in your rooting file.

Try to add/update something like that :

map.resources :items,  
:collection =\> {  
:list =\> :get  
}

Hope this helps.

Guillaume Petit  
[http://www.nomadsper.com](http://www.nomadsper.com)

---

<div class="post-metadata">

**Author:** ![torso](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/34f0e0/32.png) [@torso](https://www.ruby-forum.com/u/torso)\
**Post date:** [June 30, 2008, 1:11pm UTC](https://www.ruby-forum.com/t/def-list-routing/141742/3 "2008-06-30T13:11:21Z")

</div>

in config/routes.rb yes

---

<div class="post-metadata">

**Author:** ![torso](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/34f0e0/32.png) [@torso](https://www.ruby-forum.com/u/torso)\
**Post date:** [June 30, 2008, 12:11pm UTC](https://www.ruby-forum.com/t/def-list-routing/141742/4 "2008-06-30T12:11:03Z")

</div>

So i have to add it to the routers.rb in config directory. Am i  
right?

On Jun 30, 12:42 pm, Guillaume Petit \<rails-mailing-l…@andreas-

---

<div class="post-metadata">

**Author:** ![torso](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/34f0e0/32.png) [@torso](https://www.ruby-forum.com/u/torso)\
**Post date:** [June 30, 2008, 2:43pm UTC](https://www.ruby-forum.com/t/def-list-routing/141742/5 "2008-06-30T14:43:04Z")

</div>

I would be more concerned with the fact he’s defining $items in his  
action…

The $ signifies a global variable, which I personally have never found a  
use  
for. Change the $ to a @ to make it an instance variable so the variable  
is  
only defined for that instance.
