Reputation: 3553
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
Upvotes: 0
Views: 434
Reputation: 43153
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 :)
Upvotes: 0
Reputation: 3499
You've got a typo.
It's
Gibbon.throws_exceptions = false
Not what you've got. exceptions, not expection.
Upvotes: 1
Reputation: 4572
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
Upvotes: 0