# \#list in generated controllers

**URL:** <https://www.ruby-forum.com/t/list-in-generated-controllers/88532>\
**Category:** Rails\
**Created:** [March 12, 2007, 12:23pm UTC](https://www.ruby-forum.com/t/list-in-generated-controllers/88532 "2007-03-12T12:23:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![revlob](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/c77e96/32.png) [@revlob](https://www.ruby-forum.com/u/revlob)\
**Post date:** [March 12, 2007, 12:23pm UTC](https://www.ruby-forum.com/t/list-in-generated-controllers/88532/1 "2007-03-12T12:23:02Z")

</div>

Why does a controller created with "ruby script/generate controller  
" always have an action called list with the following lines?

01 def index  
02 list  
03 render :action =\> ‘list’  
04 end

I understand line 03 is there to define a default action, but what is  
the purpose of line 02?

---

<div class="post-metadata">

**Author:** ![revlob](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/c77e96/32.png) [@revlob](https://www.ruby-forum.com/u/revlob)\
**Post date:** [March 12, 2007, 8:28pm UTC](https://www.ruby-forum.com/t/list-in-generated-controllers/88532/2 "2007-03-12T20:28:33Z")

</div>

On Mar 12, 2007, at 12:23 , David E. wrote:

> Why does a controller created with “ruby script/generate controller  
> ” always have an action called list with the following lines?
> 
> 01 def index  
> 02 list  
> 03 render :action =\> ‘list’  
> 04 end
> 
> I understand line 03 is there to define a default action, but what is  
> the purpose of line 02?

Line #2 calls the list action so the code in that is run, setting up  
list variables etc.  
Line #3 renders the view from the list action, so the index action  
looks like the list action.

–  
Jakob S. - [http://mentalized.net](http://mentalized.net)
