Figaro“未定义的方法`require_keys'for Figaro:Module(NoMethodError)”

时间:2015-01-22 19:57:28

标签: ruby-on-rails ruby ruby-on-rails-4 rubygems environment-variables

在我的config/initializers/figaro.rb

我说:

Figaro.require_keys("MANDRILL_API_KEY")

但在运行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'

        ...

以下是我的配置: 费加罗版 - 0.7.0
Ruby版本 - ruby​​ 2.1.2p95(2014-05-08修订版45877)[x86_64-darwin13.0]
Rails版本 - 4.1.2

为了您的信息,application.yml中存在环境变量 但即使它不存在,也不应抱怨无法找到require_keys方法。

我错过了什么吗?我试过了require "figaro"

1 个答案:

答案 0 :(得分:1)

版本1.0中添加了

Figaro.require_keys。它之前被称为Figaro.require。将figaro升级到1.x或使用require方法。

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