# Rails 3: perform controller action upon selecting menu item (UJS?)

**URL:** <https://www.ruby-forum.com/t/rails-3-perform-controller-action-upon-selecting-menu-item-ujs/188438>\
**Category:** Rails\
**Created:** [May 12, 2010, 2:12am UTC](https://www.ruby-forum.com/t/rails-3-perform-controller-action-upon-selecting-menu-item-ujs/188438 "2010-05-12T02:12:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [May 12, 2010, 2:12am UTC](https://www.ruby-forum.com/t/rails-3-perform-controller-action-upon-selecting-menu-item-ujs/188438/1 "2010-05-12T02:12:58Z")

</div>

In Rails 3, I have a form that has a menu on it. I would like to  
render an area containing text fields within the form differently  
depending on what’s selected in the menu.

Prior to Rails 3, one way it appears I could do this is by using  
observe\_field on the menu and call an action in my controller that  
renders the appropriate partial which could then be swapped into a div  
in my form. In Rails 3, I’m not getting any further with this  
approach than the following error when I try to display the view the  
first time:

undefined method `observe\_field’

Am I on the right track, or is there a new and improved, UJS-correct  
way of doing this in Rails 3?

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [August 13, 2010, 3:47am UTC](https://www.ruby-forum.com/t/rails-3-perform-controller-action-upon-selecting-menu-item-ujs/188438/2 "2010-08-13T03:47:42Z")

</div>

Try this [http://railsforum.com/viewtopic.php?id=37984](http://railsforum.com/viewtopic.php?id=37984)
