We all started somewhere! Share your experience on the Get Advice: Let's Get Started Sweepstakes thread and be entered to win a $100 credit on your Constant Contact account.

CC ruby gem for Rails 3.1?

adam_jack
Occasional Participant

CC ruby gem for Rails 3.1?

I've been using the CC gem for a while, and recently upgraded from rails 2.3 to 3.1 The CC gem no longer works, giving:

 

undefined method `collect!' for #<Net::HTTPOK 200 OK readbody=true> undefined method `collect!' for #<Net::HTTPOK 200 OK readbody=true> /usr/lib/ruby/gems/1.8/gems/activeresource-3.1.0/lib/active_resource/base.rb:922:in `instantiate_collection'/usr/lib/ruby/gems/1.8/gems/constant_contact-1.1.4/lib/constant_contact/base.rb

 

but I cannot get a newer CC 'cos when I try it complains about Rails 3.1 needing a newer "builder" than CC allows.

 

Does anybody have this working?

 

     

8 REPLIES 8
Ryan_D
Employee

Hey,

 

There are two different gems right now on rubyforge for Constant Contact.  I have yet to use them as they are 3rd party source.  I believe the one you are looking for would be listed under

 

$ gem search --remote constant

 Should return 2 different constant contact gems.  One will give you the error that you are explaining and the other will install fine.  If you have any issues let me know and I will try to implement it as well.

Ryan Davis
Quality Engineer
adam_jack
Occasional Participant

Thanks for that.

 

Looking into that, the two gems seem to have completely different interfaces, so I'd have to re-write what I've done to benefit from the installable one. From what I read in the github forks I am not confident it'll work robustly.

 

FWIIW: I've been on the fence w.r.t CC integration anyway (ever since a spammer pumped accounts into my system and my integration ran up my CC costs) so I might just remove this integration from my system.

 

Thanks for your time.

CooperM
Regular Participant

Not sure if you're still wondering/thinking about this, but the problem was a change in the ActiveResource gem introduced in the upgrade to Rails 3.1. My organization maintains a fork of the gem used in a Rails 3.1 production environment at https://github.com/wishery/constant_contact, feel free to use that if you want. 

KevinZ9
Occasional Participant

Hi CooperM,

 

I took a look at your repo for your fork. It doesn't appear to work in my Rails 3.2.1 project. I see you mentioned it worked in 3.1 - have you guys looked into upgrading to Rails 3.2 yet?

 

Thanks,

Kev

CooperM
Regular Participant

We haven't, but likely will in the near future. Any idea why it doesn't work? Was there a breaking change in ActiveResource (again) ;) ?

KevinZ9
Occasional Participant

Hey Cooper,

 

After a bit more research, I realized the master branch at https://github.com/wishery/constant_contact wasn't what I needed. Instead, I grabbed the oauth branch since it looked like several updates have been made there recently.

 

using bundler...

gem "constant_contact", :git => 'git://github.com/wishery/constant_contact.git', :branch => 'oauth'

 

Appears to be working great now. Thanks!

 

Kev

Did you get it working with OAuth or are you using basic authentication?  I can get the OAuth integration to work.  I get outh_access_token_key not defined.  The code doesn't seem to get the access_token before making a call to create a connection.  I'm assuming you don't hard code those values because all you get is an api key and secret, which is to be used for the consumer.

 

Anyone know how to get OAuth working in Rails 3.2?

 

KevinZ9
Occasional Participant

Hey Derek,

 

I got it working using just basic auth. Specifically just setting these fields:

 

ConstantContact::Base.user
ConstantContact::Base.api_key
ConstantContact::Base.password 

 

I haven't tried using Oauth, unfortunately!

 

Kev

Developer Portal

View API documentation, code samples, get your API key.

Visit Page