Forum: Ruby on Rails Adding a simple action to controller

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
ce b. (Guest)
on 2007-05-09 18:11

I am trying to get the hang of rails.  It has been going well, except
now I am trying to add an action to a controller and am having trouble.
I have a LinkCategory class which extends activerecord.  In its
controller, I added a method 'display' which lists the categories with
its links.  I then created a new view, display.rhtml.

Wehn I navigate to localhost:3000/link_categories/display page, my view
is rendered, but the display method in the controller does not seem to
be exectued.  At first, I was running a find across link categories in
the controller and then attempting to use it in the view:


def display
  @link_categories = LinkCategory.find(:all)


When the view is rendered, I am told that @link_categories is a nil
object.  I know that query returns a number of rows.  I tried shorting
the method to ensure that it was being executed by adding a:
 redirect_to :action => 'list'
at the very beginning of the method, but the display view is still
rendered.  I was wondering if I had misconfigured something, or
neglected to add a mapping, that was keeping the code in the controller
from being executed.  I still have the default routes configured.  Any
help would be appreciated.

Gabriel Gironda (Guest)
on 2007-05-09 18:51
(Received via mailing list)
Calling an action 'display' is one of those unwritten things that
doesn't work. Rename it and you should be fine, perhaps 'show'.

- Gabriel
This topic is locked and can not be replied to.