Equivalent to observe_field in rails 3

Hi every one,                    i need something like populating all the states when a particular country selected. My exact requirement is, in my project management tool, when a project is selected all of its activities should be populated in the next drop down. I think before rails 3 it can be done using observe_field tag. But how to do that in rails 3 ( 3.0.10 to be precise) .

Hi Venkata,

As i already mentioned above, i am using 3.0.10 here and the default js library is prototype. But still i am not able make observe_field working.

Any ideas?

Missed that. Sorry. In that case I'd need to know more about what 'not working' means. You might want to start by looking at the page source. Is the ajax code there? If so, is its url pointing to the action you expect it to be pointing to? Using Firebug (you can't do much debugging of ajax without it), when the field changes is the ajax firing and generating the expected post in the console? If you haven't already, put some logging in the controller action. Is it getting fired? With the expected parameter(s)? Etc...

HTH, Bill

I am getting this error, when tried to access the form. NoMethodError in People#new Showing /home/local/PENNYWISE/venkatab/Desktop/rails/dynalists/app/ views/people/_form.html.erb where line #26 raised: undefined method `observe_field' for #<#<Class:0x007f511c403ed0>: 0x007f511c347cd0>Extracted source (around line #26): 23: <%= f.label :state_id, "state" %><br />24: <div id= "states_div">25: <%= f.collection_select :state_id, @states, :id, :name %>26: <%= observe_field :person_country_id, :url => { :action => "update_state_div"} , :with => :person_country_id %>27: </div>28: </div>29: <div class="actions">Trace of template inclusion: app/ views/people/new.html.erb

i am following this http://thecloudview.com/dynamic-select-lists-with-ruby-on-rails-and-ajax/ , and doing the same.I doubt prototype in rails3 have no method of observe_field.

looking at http://apidock.com/rails/v2.3.8/ActionView/Helpers/PrototypeHelper/observe_field

i thinkt that method is opt out on 2.3.8

maybe http://railscasts.com/episodes/88-dynamic-select-menus

there is a revised version, but it’s for subscriber only

Ahmy Yulrizka

looking here solved my problem.

http://gregmoreno.ca/rails-3-upgrade-part-4-prototype-helpers-and-javascript/

I think observe_field is a good method to be included. Can't understand why it's not there. Thank you all!

observe_field was deprecated as rails 3 is towards being javascript agnostic and requires the developer to have a good grasp of javascript.

K.M. wrote in post #1040052:

observe_field was deprecated as rails 3 is towards being javascript agnostic and requires the developer to have a good grasp of javascript. Unobtrusive JavaScript in Rails 3 — Simone Carletti

+1

I also agree with the deprecation, and ultimate removal, of the observe_field helpers. The same behavior can be duplicated with jQuery. Rails should not include helpers that are tightly bound to any specific JavaScript library.

http://puneetitengineer.wordpress.com/2008/06/01/ruby-on-rails-auto-select/

This might be helpful to u…