amalc / rubyzoho

Abstracting Zoho’s API into a set of Ruby classes, with reflection of Zoho’s fields using a more familiar ActiveRecord lifecycle, but without ActiveRecord. Works with Rails and Devise.
MIT License
62 stars 57 forks source link

Cannot update custom fields if Lead initialized with parameters #48

Open jcmorrow opened 9 years ago

jcmorrow commented 9 years ago

If we have a custom field on a lead called "Custom Field One" the following code works:

lead = RubyZoho::Crm::Lead.new
lead.custom_field_one = "a new value"

However, the next piece of code will raise a NoMethodError

lead = RubyZoho::Crm::Lead.new(last_name: "Smith")
lead.custom_field_one = "a new value"

I tried to dig into the code to better understand where the custom fields get retrieved but I couldn't really find what I was looking for. With some guidance I'd be happy to write a solution.

amalc commented 9 years ago

John, a custom field name needs to be a legal ruby variable name at this stage. There is a fix, untested as yet, in master that maps field names from and to legal names in the api to Zoho names. HTH.