Forum: Ruby on Rails observe_field question

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
a.filipowski (Guest)
on 2005-12-06 22:13
(Received via mailing list)
Thanks all for answering my previous questions.

This one is based off of my last question involving graphs and
allowing users to filter through the data however they wish in my
app. The way I envision allowing the users to filter is by setting up
a rules view similar to that of apple's mail rules builder basically
I have a set of drop downs that get built based on different criteria
dynamically. These drop-downs are created based on a users selection
from the first select box and so on. I am using observe_field to
watch the selection of the various boxes and than building new ones
based on data from the database. At the end of each row is an add and
delete button. When you click on add a new row appears at the bottom
of the list (using ajax prettyness). Where I am running into an issue
is that each box needs to be unique so that when I submit the form I
get all the parameters that I need to run the query and display the
results.

Also I am using select_tag for my drop-downs as these fields are not
directly associated with any model in particular.

What is the correct way to observe a select box where the div that
wraps the content as well as the name of the select box is dynamic?
can I observe a field that is associated with an array? I have tried
the following:

<%= select_tag('filter_type_#{@params[:rule_num]}', "<option> </
option><option>Company</option><option>Division</option><option>Date</
option>") %>
                           <%= observe_field('filter_type_#{@params
[:rule_num]}',
                                             :update =>
'filter_container_#{@params[:rule_num]}',
                                             :url => { :controller =>
'take', :action => :lookup_filter_type },
                                             :with =>
"'filter_type_'+#{@params[:rule_num]}+'='+escape(value)
+'&object_id='+#{@object.id}+'&rule_num=1'") %>

but nothing happens (at least not what should happen)

Any help would be appreciated.

Andrew
a.filipowski (Guest)
on 2005-12-08 06:38
(Received via mailing list)
Well i am an idiot I was able to get this to work by removing the :
and quoting the variable in the params statement. Had a huge
brainfart I guess.

Andrew
This topic is locked and can not be replied to.