我尝试在我的应用中同时使用红宝石单元https://github.com/olbrich/ruby-units和炼金术https://github.com/halogenandtoast/alchemist宝石进行转换。即使在生产模式下,一切都在本地完美。
然而,在我的Linode上,转换会引发异常,即使炼金术宝石在生产rails控制台中完美运行。
在我的rails应用程序中使用这些红宝石宝石是否需要额外的必需步骤或配置?我是否需要在初始化程序中调用require 'alchemist'
?纯红宝石如何适应Rails,它们是如何配置的?
以下是我的Gemfile中的行:
gem 'alchemist'
这是生产控制台输出(有效):
deployer@li60-239:~/apps/saute/current$ bundle exec rails c production
Loading production environment (Rails 3.2.2)
irb(main):001:0> Alchemist
=> Alchemist
irb(main):002:0> 1.tablespoon
=> 1.0
irb(main):003:0> 1.tablespoon.class
=> Alchemist::NumericConversion
但在我的应用程序中,我的日志中出现异常:
Exception in base quantity method: undefined method `tablespoon' for #<BigDecimal:beb7548,'0.1E1',4(8)>
Quantity: 1.0
更新:
我创建了config/initializers/alchemist.rb
:
require 'alchemist'
这并没有在开发中导致本地问题。一切仍然有效。但后来我在制作中遇到了错误的错误:
/home/deployer/apps/saute/shared/bundle/ruby/1.9.1/gems/activesupport- 3.2.1 / lib / active_support / dependencies.rb:251:在`require&#39;:没有这样的文件加载 - 炼金术士(LoadError)
如何配置此功能!