# Observe\_field default parameter

**URL:** <https://www.ruby-forum.com/t/observe-field-default-parameter/114925>\
**Category:** Rails\
**Created:** [September 18, 2007, 9:18pm UTC](https://www.ruby-forum.com/t/observe-field-default-parameter/114925 "2007-09-18T21:18:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![aspartam](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ebca7d/32.png) [@aspartam](https://www.ruby-forum.com/u/aspartam)\
**Post date:** [September 18, 2007, 9:18pm UTC](https://www.ruby-forum.com/t/observe-field-default-parameter/114925/1 "2007-09-18T21:18:30Z")

</div>

Hi fellow rubians 😉

Im trying to populate one collection\_select from another and I got it  
pretty much down I think:

VIEW 1 (first combobox):  
\<%= collection\_select( :doctype, :name, @doctypes, :id, :name, options =  
{:prompt =\> “Select doctype”}) %\>

\<%= observe\_field ‘doctype[name]’, :frequency =\> 2,  
:update =\> ‘fieldtypes’,  
:url =\> {:action =\> ‘doctype\_changed’,  
} %\>

Second combobox is about the same. Controller method:

def doctype\_changed  
@doctype\_pages, @doctypes = paginate :doctypes  
@fieldtypes = @doctypes[???].fieldtypes  
render :partial =\> “fieldtype”, :layout =\> false  
end

Now this works fine if i give it a number in the ??? part and info  
pops up in the second combobox just fine. Now obviously what I want to  
is to pass the value of combobox 1 to this method, but I cant figure out  
what this parameter is called.

In the errormessage it states I send the correct value, I just need to  
know how to reference it in my doctype\_changed-method:

Request  
Parameters: {“1”=\>""}

(etc.)

Thanks for any help 🙂

---

<div class="post-metadata">

**Author:** ![aspartam](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ebca7d/32.png) [@aspartam](https://www.ruby-forum.com/u/aspartam)\
**Post date:** [September 19, 2007, 1:53pm UTC](https://www.ruby-forum.com/t/observe-field-default-parameter/114925/2 "2007-09-19T13:53:16Z")

</div>

> \<%= observe\_field ‘doctype[name]’, :frequency =\> 2,  
> :update =\> ‘fieldtypes’,  
> :url =\> {:action =\> ‘doctype\_changed’,  
> } %\>

I got it to work by adding :id =\> :doctype now. But the id param in  
always contains “0” (first choice in the dropdown). Any ideas why?
