Problem with rails and AJAX

Hi,

I have a very simple page with a drop down select list and I want that a
portion of this page gets updated each time a new selection is done on
the select list.

This is my page with the select list (edit view_sites.html.erb):

<% form_for :site, :url => { :action => :edit_site } do |form| %>

<%= form.label(:name, "Location Code:") %> <%= collection_select(:VMetaLocationPopulated, :location_code, loc_entities, :location_code, :location_code, options ={:prompt => "-Select a Location Code"}) %> <%= observe_field 'VMetaLocationPopulated_location_code', :url => {:action => :update_edit_view, :form_authenticity_token => form_authenticity_token }, :update => :dynamic_content, :with => '"locid="+element.value', :locals => { :form => form }, :loading => "Element.show('indicator')", :complete => "Element.hide('indicator')" %>

<% end %>

And the action method (update_edit_view) in the controller class is
empty since I just want it to forward to the dynamic_content page. So
this is that page (update_edit_view.erb):

<%if(params[:locid] != nil)%>
<%= form.label(:name, “Location Name:”) %>
<%= form.text_field(:locid, :size => 40) %>
<%else%>

<%end%>

So this should work but the error I get is:

ArgumentError in Main#update_edit_view
Showing app/views/main/update_edit_view.erb where line #3 raised:

wrong number of arguments (0 for 1)
Extracted source (around line #3):

1:
2: <%if(params[:locid] != nil)%>
3: <%= form.label(:name, “Location Name:”) %>
4: <%= form.text_field(:locid, :size => 40) %>
5: <%else%>

Why is it complaining about the form.label method? It works fine if I
copy paste it on the main page but in this partial one it does not work.
I assume it has got to do with not being able to find the ‘form’
variable but I passed it on by using the line: :locals => { :form =>
form }

So why doesn’t it work?

Noone knows how to pass a form reference to a partial page when using
observe_field?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs