Variable not being populated?

I have this order form that auto populates these fields as you step
through
provider:
customer:
location:
device:

Provider field works great, and then I move to Customer. I need to
capture the providerId from the previous query (although it displays
provider name, the XML returns the Id as well), and use it to do a look
up on customers (SELECT * FROM Customers where providerId = ?). Where am
I going wrong?

but my params[providerId] is blank. Here is the provider and customer
sections in the orderscontroller.rb

def auto_complete_for_provider_order
@provider = params[:order][:provider].downcase
@providers = Provider.call_provider_list_service_order(@provider)

render :partial => 'auto_complete_for_provider_order', :locals =>

{:providers => @providers}
end

def auto_complete_for_customer_service_order
@customer = params[:order][:customer].downcase
@provider = params[:order][:provider].downcase
@provider_id = params[:providerId]
@customers =
Customer.call_customer_list_service_order(@provider_id)
render :partial => ‘auto_complete_for_customer_service_order’,
:locals => {:customers => @customers}
end

Here is my provider.rb model

def self.call_provider_list_service_order(provider = ‘’)
xml = “”

  x = Builder::XmlMarkup.new(:target => xml)
  x.instruct!
   x.Automanager("xmlns:xsi" =>

http://www.w3.org/2001/XMLSchema-instance”) {
x.request {
x.header {
x.logonid “xxx”
x.password “yyy”
x.version “1.3”
x.requestType “getProviderList”
}
x.body {
x.getProviderList {
} # end getProviderList
} # end body
} # end request
} # end Automanaager

result = post(xml)


doc = REXML::Document.new result.body
providers = {}

provider_nodes = REXML::XPath.each( doc, "//provider" ) do |element|
  if element.elements["name"].text.downcase

=~/^#{provider.downcase}/
providers[element.elements[“name”].text]=element.elements[“providerId”].text
end
end
providers
end

And here is my customer.rb model

def self.call_customer_list_service_order(provider)
xml = “”
x = Builder::XmlMarkup.new(:target => xml)
x.instruct!
x.Automanager(“xmlns:xsi” =>
http://www.w3.org/2001/XMLSchema-instance”) {
x.request {
x.header {
x.logonid “xxx”
x.password “yyy”
x.version “1.3”
x.requestType “getCustomerList”
}
x.body {
x.getCustomerList {
x.providerId provider
} # end getCustomerList
} # end body
} # end request
} # end Automanaager

result = post(xml)

doc = REXML::Document.new result.body
customers = {}

customer_nodes = REXML::XPath.each( doc, "//customer" ) do |element|
  if element.elements["name"].text =~/^#{@customer}/
    customers[element.elements["name"].text]=element.elements["customerId"].text
  end
end
customers

end

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