Passing Multiple Parameters from observe_field

I need to pass through two parameters to a controller method from an
observe_field : the value of the field and another local variable.

I can get it working for either of the two, but not for both.

This is what I’m got in the form partial I’m trying to write
(purchaser_country_id is coming in as a :local) -

Zip Code
<%= text_field 'order', 'purchaser_zipcode', :size => 20 %>

<% if Zipcode.exists?([“state_id in (select id from dbfox001.states
where
country_id = ?)”, purchaser_country_id]) %>

<%= ‘Zipcodes exist for ’ + purchaser_country_id.to_s %>
<%=
observe_field :order_purchaser_zipcode,
:update => ‘purchaser_loc2’,
:url => { :controller => ‘order’, :action =>
‘findzip’ },
:with
=>
"‘purchaser_country_id=’+purchaser_country_id.to_s+’&purchaser_zipcode=’+encodeURIComponent(value)"
%>
<% else %>

<%= 'No zipcodes for ’ + purchaser_country_id.to_s %>
<% end %>

<%= render :partial => "purchaser_location2", :locals => {:purchaser_country_id => purchaser_country_id, :purchaser_zipcode => ''} %>
  <p><label for="order_purchaser_city">City</label><br/>
  <%= text_field 'order', 'purchaser_city', :size => 50  %></p>

If one of the fields is a literal it works : for example -

:with
=>
“‘purchaser_zipcode=’+encodeURIComponent(value)+’&purchaser_country_id=’+‘101’”

Any help appreciated.

Thanks

Phil

I had the same problem up until a couple of minutes ago. Try this:

with =>
“‘purchaser_country_id=#{purchaser_country_id}&purchaser_zipcode=’+encodeURIComponent(value)”

Sean

Sean,

Thanks for that : I managed to resolve this last night (with the same
solution) after some help on the RoR chat forum.

Thanks very much.

Phil

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