# Adding a simple action to controller

**URL:** <https://www.ruby-forum.com/t/adding-a-simple-action-to-controller/103710>\
**Category:** Rails\
**Created:** [May 9, 2007, 4:11pm UTC](https://www.ruby-forum.com/t/adding-a-simple-action-to-controller/103710 "2007-05-09T16:11:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![cbinckly](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/b9e5f3/32.png) [@cbinckly](https://www.ruby-forum.com/u/cbinckly)\
**Post date:** [May 9, 2007, 4:11pm UTC](https://www.ruby-forum.com/t/adding-a-simple-action-to-controller/103710/1 "2007-05-09T16:11:29Z")

</div>

Hi,

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)
end
`

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.

Thanks.

---

<div class="post-metadata">

**Author:** ![cbinckly](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/b9e5f3/32.png) [@cbinckly](https://www.ruby-forum.com/u/cbinckly)\
**Post date:** [May 9, 2007, 4:51pm UTC](https://www.ruby-forum.com/t/adding-a-simple-action-to-controller/103710/2 "2007-05-09T16:51:47Z")

</div>

Calling an action ‘display’ is one of those unwritten things that  
doesn’t work. Rename it and you should be fine, perhaps ‘show’.

- Gabriel
