Forum: Ruby on Rails The reason for 'list'

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Richard <> (Guest)
on 2005-12-08 07:38
Hi,

When ever I use scaffolding to start off and provide the basics for
writing to, and reading from, a database table I notice that in the
controller it always has:

def index
  list
  render :action => 'list'
end

I understand what the index method does, and I understand what render
does.  What I don't understand is why has 'list' there before the render
method?  What is this call doing?

The reason I am asking is that when I take 'list' line out of the index
method, the list action will not work?  Why is this?

Thanks for any help,
Richard
Pat M. (Guest)
on 2005-12-08 08:11
(Received via mailing list)
Hi Richard,

When you call render, all it does it spit some output to the browser.
So in this particular case, it's simply displaying the output of the
list.rhtml file.  For that to work though, you need to perform the
logic in the view action, which in the case of list is to simply
create an array of objects.  The index method then is calling the list
action to perform the code there, and then uses the list.rhtml
template as output.

Pat


On 12/7/05, Richard <removed_email_address@domain.invalid>
This topic is locked and can not be replied to.