echo echo - 6 months ago 8
Ruby Question

Figaro "undefined method `require_keys' for Figaro:Module (NoMethodError)"

In my

config/initializers/figaro.rb


I put:

Figaro.require_keys("MANDRILL_API_KEY")


but got the following when running
rails s
:

Exiting
/Users/guycao/code/oms_on_rails/config/initializers/figaro.rb:1:in `<top (required)>': undefined method `require_keys' for Figaro:Module (NoMethodError)
from /Users/guycao/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.2/lib/active_support/dependencies.rb:241:in `load'
from /Users/guycao/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.2/lib/active_support/dependencies.rb:241:in `block in load'
from /Users/guycao/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.2/lib/active_support/dependencies.rb:232:in `load_dependency'
from /Users/guycao/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.2/lib/active_support/dependencies.rb:241:in `load'

...


Here are my configs:
Figaro version - 0.7.0

Ruby version - ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin13.0]

Rails version - 4.1.2

For your information, the environmental variable does exist in the
application.yml

but even if it didn't exist, it shouldn't complain about not being able to find the
require_keys
method.

Am I missing something? I tried
require "figaro"

Answer

Figaro.require_keys was added in version 1.0. It was previously called Figaro.require. Either upgrade figaro to 1.x or use the require method.

https://github.com/laserlemon/figaro/blame/master/CHANGELOG.md#L6

Comments