0

I'm looking at using the Gibbon gem for Mailchimp integration and I would like to add my API details in config/initializers/gibbon.rb

The gem takes in a few things: API KEY, timeout, etc..

I wanted to know the best way to extract this from my controller to an initalizer.

# config/initializer/gibbon.rb

Gibbon.api_key = "my-api-key"
Gibbon.timeout = 15
Gibbon.throws_expection = false

The above fails with an error: gibbon.rb:38:in 'merge': can't convert false into Hash (TypeError)

I wanted to know what is the best practise for this in Rails 3.2.x

3 Answers 3

1

You've got a typo.

It's

 Gibbon.throws_exceptions = false

Not what you've got. exceptions, not expection.

Sign up to request clarification or add additional context in comments.

1 Comment

Glad to help. We've all been there!
0

I don't understand your question at all, but try something like:

# config/initializer/gibbon.rb
module Gibbon
     Gibbon.api_key = "my-api-key"
     Gibbon.timeout = 15
     Gibbon.throws_expection = false
end

1 Comment

Thanks for replying Fernando, I appreciate it. I have issues using the gem because when I enter the api details and options as an initializer it fails. Unfortunately, using a module Gibbon fails also.
0

Well, look at the error you're getting:

gibbon.rb:38:in 'merge': can't convert false into Hash (TypeError)

So, what's on line 38 of your initializer? You're only showing us a few lines. It looks like on line 38 you're passing false to an argument that is expecting a hash.

If you have the three lines from your question, and only those three lines, saved in config/initializers/gibbon.rb it should do what you're expecting.

If you want to paste your whole initializer file into your question I'll come back and check again, and will add to this answer if there's something visibly wrong.

As Edward pointed out, you've just got a typo :)

2 Comments

Hi Andrew, thanks for taking the time to check out my problem. Sorry, the line the error refers to is the Gem. Setting up a simple Gibbon.api_key = "my-api-key" without any other arguements eg. Gibbon.timeout = 15 works. But when I start adding on settings to the config/initalizer/gibbon.rb is where I'm having problems. I think it requires a hash?
Typo, see Edward's answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.