websdotcom / constant_contact

Activeresource wrapper gem for the Constant Contact API
MIT License
23 stars 22 forks source link

Exception trying to save existing contact without contact_lists #10

Open boone opened 13 years ago

boone commented 13 years ago

The gem raises an exception when you try to save an existing contact which has no contact lists (e.g. one that is in the do-not-mail group).

> contact = ConstantContact::Contact.find(1)
 => #<ConstantContact::Contact:0x100000000 @prefix_options={}, @attributes={"Status"=>"Do Not Mail", ...

> contact.contact_lists
 => nil

> contact.save
NoMethodError: You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.sort
    from .../lib/constant_contact/contact.rb:21:in `to_xml'
...

I'm new to Constant Contact, so perhaps you aren't allowed to update contacts that are in the do-not-mail group, but in that case there should be a more meaningful error. If you are allowed to update these contacts, there should be a way to fix this.