简体   繁体   English

将变量添加到config / development.rb rails引擎

[英]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.

相关问题 找不到config / environments / development.rb命令 - config/environments/development.rb command not found 迁移 Rails 6.0.34 -&gt; 6.1 后,我无法在 config/environments/development.rb 中使用 model - After migration Rails 6.0.34 -> 6.1 I can't use model inside the config/environments/development.rb Rails 3在config / environments / development.rb中从lib加载类的问题 - Rails 3 problem loading classes from lib in config/environments/development.rb rails生成rspec:install config / environments / development.rb:1:在`<top(required)>':undefined method`configure' - rails generate rspec:install config/environments/development.rb:1:in `<top (required)>': undefined method `configure' 在Rails项目中,我们将所有常量定义放在config / environment.rb中,将更多特定定义放在config / environments / development.rb中? - In a Rails project, we put all constants definition in config/environment.rb and more particular ones in config/environments/development.rb? 无法读取development.rb中的配置值 - Can't read a config value in development.rb git pull说config / environments / development.rb未提交 - git pull says config/environments/development.rb is not committed 如何从gem中添加到应用程序的development.rb配置 - how to add to a application's development.rb config from in a gem 配置Rails以在development.rb中生成正确的第一行 - Configuring Rails to generate the correct first line in development.rb 没有development.rb的情况下如何运行Rails应用程序 - how is it possible to run a rails app without development.rb
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM