.erb
.erb
.rb
<div id="customer_out">
<%= render :partial => "customer", object => @customer_out%>
</div>
.erb
<%= f.text_field :username, :onchange => remote_function(:update => "customer_out",
:with => "'username='+$(this).value + '&come_from='+$('customer_out[come_from]').value",
:url =>{:action => 'check_customer'} ) %>
.rb
def check_customer
@customer_out = CustomerOut.find(:first, :conditions => ["username = ? and come_from = ?", params[:username], params[:come_from]])
if @customer_out
@customer_out = CustomerOut.new
@consignee = @customer_out.customer.consignees.find(:first)
end
render :partial => 'customer'
end