Forum: Ruby on Rails Error: too much recursion

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.
damon (Guest)
on 2005-11-16 22:37
(Received via mailing list)
Good day.

I am getting a javascript error when using multiple observe_field method
calls that simply states "Error: too much recursion".

View

		<td><label for="purchase_order_cutomer_address">Customer
Address:</label></td>
		<td><div id="po_customer_address"></div></td>
	</tr>
	<tr>
		<td><label for="purchase_order_shipper_address">Ship
Via:</label></td>
		<td><div id="po_shipper_address"></div></td>
		<td>&nbsp;</td>
		<td><label for="purchase_order_credit_limit">Credit
Limit:</label></td>
		<td><div id="po_credit_limit"></div></td>
		<td><label for="purchase_order_current_balance">Current
Bal:</label></td>
		<td><div id="po_current_balance"></div></td>
	</tr>
</table>
<%= observe_field(:purchase_order_customer_id,
			:update			=> :po_customer_address,
			:url				=> { :action =>
:get_customer_address },
			:with				=>
"'customer_id='+escape(value)")%>
<%= observe_field(:purchase_order_customer_id,
			:update 		=> :po_credit_limit,
			:url				=> { :action =>
:get_customer_credit_limit },
			:with				=>
"'customer_id='+escape(value)")%>

Controller
  def get_customer_address
    form_customer_id = params[:customer_id]
    @found_customer = Customer.find(form_customer_id)
  end

  def get_customer_credit_limit
    form_customer_id = params[:customer_id]
    @found_customer_limit = Customer.find(form_customer_id)
  end

Returning Views

get_customer_address.rhtml
<%= text_field("purchase_order", "customer_address", :readonly =>
"readonly", "size" => 25, :value => @found_customer.address) %><br />
<%= text_field("purchase_order", "customer_city", :readonly =>
"readonly", "size" => 10, :value => @found_customer.city) %>
<%= text_field("purchase_order", "customer_state", :readonly =>
"readonly", "size" => 2, :value => @found_customer.state) %>
<%= text_field("purchase_order", "customer_postal_code", :readonly =>
"readonly", "size" => 5, :value => @found_customer.postal_code) %>

get_customer_credit_limit.rhtml
<%= text_field("purchase_order", "customer_credit_limit", :readonly =>
"readonly", :value => @found_customer_limit.credit_limit) %>

Does anyone know why this would happen?
Can you not call multiple observe_field methods on the same element in a
form?
By removing the observe_field on the customer_credit_limit the
customer_address works perfectly.
But when I add the customer_credit_limit back in, I get the recursion
error.

Any input would be greatly appreciated.

M Damon H.
Project Manager
IFWORLD, Inc.
www.ifworld.com <http://www.ifworld.com/>
"..as we're sung to sleep by philosophies that sing save the trees and
kill the children...." -- while you were sleeping (casting crowns)
This topic is locked and can not be replied to.