Ruby on rails 3.2 quickbook gem:在quickbook中推送邮政编码、城市、第1行、第2行字段?
我正在使用rails 3.2和QuickeBook gem连接quickbooks online。现在我的rails应用程序和quickbook之间的连接已经完成,但我在其中面临新的问题 当我尝试在quickbook中保存customer.name时,它通过我的控制器成功保存,但如果我尝试传递customer.id、customer.email、customer.zipcode、customer.phone等字段,则会生成错误。如何使用quickeebook gem保存此数据 哦,对不起,我忘了解释错误和代码Ruby on rails 3.2 quickbook gem:在quickbook中推送邮政编码、城市、第1行、第2行字段?,ruby-on-rails-3.2,rubygems,quickbooks,Ruby On Rails 3.2,Rubygems,Quickbooks,我正在使用rails 3.2和QuickeBook gem连接quickbooks online。现在我的rails应用程序和quickbook之间的连接已经完成,但我在其中面临新的问题 当我尝试在quickbook中保存customer.name时,它通过我的控制器成功保存,但如果我尝试传递customer.id、customer.email、customer.zipcode、customer.phone等字段,则会生成错误。如何使用quickeebook gem保存此数据 哦,对不起,我忘了
oauth_client = OAuth::AccessToken.new($qb_oauth_consumer, current_login.access_token, current_login.access_secret)
#creating customer in quickbooks
customer_service = Quickeebooks::Online::Service::Customer.new
customer_service.access_token = oauth_client
customer_service.realm_id = current_login.realm_id
customer_service.list
customer = Quickeebooks::Online::Model::Customer.new
customer.name = "New Customer2"
customer.email_address = "new_customer1@gmail.org"
customer.given_name = "New"
customer.middle_name = "H."
customer.family_name = "Customer"
customer.phone = "9845845854"
customer.web_site = "www.google.com"
customer.billing_address = "this is billing address"
customer.city = "Bangalore"
customer_service.create(customer)
假设我想在quickbooks online中插入这些字段。但这会产生如下错误:
undefined method `to_xml' for "9845845854":String
family_name之前的其他字段工作正常,但对于电话、地址、网站、城市等字段,每当我想将这些值推送到quickbooks时,都会出现如下错误:
undefined method `to_xml' for "9845845854":String
undefined method `to_xml' for "www.google.com":string
undefined method `city=' for #<Quickeebooks::Online::Model::Customer:0xb5150e68>
“9845845854”的未定义方法“to_xml”:字符串
“www.google.com”的未定义方法“to_xml”:string
未定义的方法“city=”用于#
正在进行中。如何修复此错误?最后,问题解决了 邮政编码、第1行、第2行、城市等字段与地址字段相关。因此,与其写作
customer.city = "Bangalore"
我们必须首先继承地址模型,并将地址数组传递给客户,如:
address = Quickeebooks::Online::Model::Address.new
address.line1 = "address 1"
address.line2 = "my fake address"
address.city = "awesome city"
address.country_sub_division_code = "wooooooo..."
address.postal_code = "12345"
customer.addresses = [address]
同样,对于电话号码:
phone1 = Quickeebooks::Online::Model::Phone.new
phone1.device_type = "Primary"
phone1.free_form_number = "973-855-0394"
phone2 = Quickeebooks::Online::Model::Phone.new
phone2.device_type = "Mobile"
phone2.free_form_number = "5458565298"
phone3 = Quickeebooks::Online::Model::Phone.new
phone3.device_type = "Fax"
phone3.free_form_number = "5458565298"
customer.phones = [phone1, phone2, phone3]
等等……你在哪里,ruby代码?具体来说,你会遇到什么错误?