# Params colllection\_select observe\_field

**URL:** <https://www.ruby-forum.com/t/params-colllection-select-observe-field/144973>\
**Category:** Rails\
**Created:** [August 4, 2008, 9:14pm UTC](https://www.ruby-forum.com/t/params-colllection-select-observe-field/144973 "2008-08-04T21:14:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tomtt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e47c2d/32.png) [@tomtt](https://www.ruby-forum.com/u/tomtt)\
**Post date:** [August 4, 2008, 9:14pm UTC](https://www.ruby-forum.com/t/params-colllection-select-observe-field/144973/1 "2008-08-04T21:14:13Z")

</div>

Hi,

i have 2 dropdowns which are dependent from each other:  
ItemCategory has many ItemGroups

* * *

/Item/New.html

\<%= javascript\_include\_tag “prototype” %\>  
\<%=  
collection\_select(:x, :id, ItemCategory.find(:all,  
:conditions=\>[‘division\_id=?’,session[:divisionid]]), :id, :title, :id  
=\> :itemcategory\_id )  
%\>  
\<%= observe\_field :x\_id, :update =\> :ajaxmessage, :url =\> { :action =\>  
“changex”} %\>

## 

items\_controller.rb  
def changex

```
  #render :text => "test" #OK
  render :text => params[:x][:id]
  >>>>>>>>>NIL NIL NIL NIL

```

…/\*

# @servers = ItemGroup.find\_all\_by\_item\_category\_id(2)

# render :partial =\> “person”

## …\*/ end

\_person  
\<%= collection\_select(:x, :bla , @servers, :id, :title ) %\>

* * *

if u use the same code in a form where i specify the action within the  
form header, everything is good and i recieve the id from the  
params-tag. But it is no tworking out of that observer - WHY? params is  
always NIL!!!  
If i debug it in FFBug, i can see the correct POST-Value…

Any Help is really appreciated, im trying to figure this out since  
days…

---

<div class="post-metadata">

**Author:** ![tomtt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e47c2d/32.png) [@tomtt](https://www.ruby-forum.com/u/tomtt)\
**Post date:** [August 5, 2008, 3:31am UTC](https://www.ruby-forum.com/t/params-colllection-select-observe-field/144973/2 "2008-08-05T03:31:25Z")

</div>

On Aug 4, 8:14 pm, Tom T. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> if u use the same code in a form where i specify the action within the  
> form header, everything is good and i recieve the id from the  
> params-tag. But it is no tworking out of that observer - WHY? params is  
> always NIL!!!  
> If i debug it in FFBug, i can see the correct POST-Value…

I expect you’ll find that the parameter simply doesn’t have the name  
you expect.  
Look at the api examples and you’ll see that if you pass :with =\>  
‘something’ to observe\_field  
then the observed value is stored at params[:something]. Can’t  
remember off the top of my head what the parameter name will be if you  
don’t specify :with (possibly just params[:value], but definitely not  
params[:x][:id])

Fred
