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.
72737f7f0640b5a72a3e897feed91f36?d=identicon&s=25 ce bi (cbinckly)
on 2007-05-09 16: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.

Fc49ff6d82732b73a94be2974b4dd3df?d=identicon&s=25 Gabriel Gironda (Guest)
on 2007-05-09 16: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.