[英]Adding Variables to config/development.rb rails engine
Currently confused on configuring my application. 目前对配置我的应用程序感到困惑。 I'm currently trying to initialize a new object in config/development.rb
我目前正在尝试在config / development.rb中初始化一个新对象
following this sample app tutorial https://www.wepay.com/developer/resources/wefarm-tutorial 遵循此示例应用程序教程https://www.wepay.com/developer/resources/wefarm-tutorial
My problem is I'm building the application the modular way. 我的问题是我正在以模块化方式构建应用程序。 where everything sits in engines.
一切都在引擎中。 The wepay gem is currently installed within the core engine of the application.
wepay gem目前已安装在应用程序的核心引擎中。 I'm confused on itializing the new WePay object.
我对迭代新的WePay对象感到困惑。
I keep getting the error uninitialized constant Wepay 我不断收到错误未初始化的常量Wepay
can someone maybe help to see what I'm doing wrong, am I missing a step since my application is being built within engines instead of Monolithic ? 有人可以帮忙看看我做错了什么吗,因为我的应用程序是在引擎内而不是在Monolithic内构建的,我是否缺少一步?
Any thoughts or help would be great 任何想法或帮助都会很棒
If you wish to use an initializer - code that should run before the engine is loaded - the place for it is the config/initializers folder.
如果要使用初始化程序-应该在加载引擎之前运行的代码-放置在config / initializers文件夹中。
http://guides.rubyonrails.org/engines.html
http://guides.rubyonrails.org/engines.html
Rails will require every file in the config/initializers
directory as part of the initialization process - when you mount an engine rails will also look in the engines config/initializers
directory. 在初始化过程中,Rails将需要
config/initializers
目录中的每个文件-挂载引擎时,rails还将在engine config/initializers
目录中查找。
# config/initializers/we_pay.rb
# Note that globals are not thread safe.
$wepay = WePay::Client.new(
ENV['WEPAY_CLIENT_ID'],
ENV['WEPAY_CLIENT_SECRET'],
true
)
See also: 也可以看看:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.