Money Gem - nil:NilClass 的未定义方法“each”
Money Gem - undefined method `each' for nil:NilClass
我正在尝试在我的机器上使用金钱 gem,但出现以下错误。
我指的是这个 link - https://github.com/RubyMoney/money/blob/master/README.md
Money.new(1000, "USD").exchange_to("EUR")
NoMethodError: undefined method `each' for nil:NilClass
from /home/dev/new_hotspotting-backend/shared/bundle/ruby/2.3.0/gems/money-currencylayer-bank-0.5.3/lib/money/bank/currencylayer_bank.rb:93:in `update_rates'
from /home/dev/new_hotspotting-backend/shared/bundle/ruby/2.3.0/gems/money-currencylayer-bank-0.5.3/lib/money/bank/currencylayer_bank.rb:142:in `expire_rates!'
from /home/dev/new_hotspotting-backend/shared/bundle/ruby/2.3.0/gems/money-currencylayer-bank-0.5.3/lib/money/bank/currencylayer_bank.rb:108:in `get_rate'
from /home/dev/new_hotspotting-backend/shared/bundle/ruby/2.3.0/gems/money-6.7.0/lib/money/bank/variable_exchange.rb:109:in `exchange_with'
from /home/dev/new_hotspotting-backend/shared/bundle/ruby/2.3.0/gems/money-6.7.0/lib/money/money.rb:434:in `exchange_to'
from (irb):17
我不明白为什么会出现此错误。
我正在使用以下版本赚钱 gems
money (6.9.0, 6.7.0)
money-currencylayer-bank (0.5.4)
尝试:
对象需要手动指定汇率
Money.add_rate("USD", "EUR", 0.5)
Money.us_dollar(100).exchange_to("EUR")
输出:
2.3.0 :009 >
2.3.0 :010 > require 'money'
=> true
2.3.0 :011 > Money.add_rate("USD", "EUR", 0.5)
=> 0.5
2.3.0 :012 > Money.us_dollar(100).exchange_to("EUR").currency
=> #<Money::Currency id: eur, priority: 2, symbol_first: true, thousands_separator: ., html_entity: €, decimal_mark: ,, name: Euro, symbol: €, subunit_to_unit: 100, exponent: 2, iso_code: EUR, iso_numeric: 978, subunit: Cent, smallest_denomination: 1>
2.3.0 :013 >
2.3.0 :014 >
我正在尝试在我的机器上使用金钱 gem,但出现以下错误。
我指的是这个 link - https://github.com/RubyMoney/money/blob/master/README.md
Money.new(1000, "USD").exchange_to("EUR")
NoMethodError: undefined method `each' for nil:NilClass
from /home/dev/new_hotspotting-backend/shared/bundle/ruby/2.3.0/gems/money-currencylayer-bank-0.5.3/lib/money/bank/currencylayer_bank.rb:93:in `update_rates'
from /home/dev/new_hotspotting-backend/shared/bundle/ruby/2.3.0/gems/money-currencylayer-bank-0.5.3/lib/money/bank/currencylayer_bank.rb:142:in `expire_rates!'
from /home/dev/new_hotspotting-backend/shared/bundle/ruby/2.3.0/gems/money-currencylayer-bank-0.5.3/lib/money/bank/currencylayer_bank.rb:108:in `get_rate'
from /home/dev/new_hotspotting-backend/shared/bundle/ruby/2.3.0/gems/money-6.7.0/lib/money/bank/variable_exchange.rb:109:in `exchange_with'
from /home/dev/new_hotspotting-backend/shared/bundle/ruby/2.3.0/gems/money-6.7.0/lib/money/money.rb:434:in `exchange_to'
from (irb):17
我不明白为什么会出现此错误。 我正在使用以下版本赚钱 gems
money (6.9.0, 6.7.0)
money-currencylayer-bank (0.5.4)
尝试:
对象需要手动指定汇率
Money.add_rate("USD", "EUR", 0.5)
Money.us_dollar(100).exchange_to("EUR")
输出:
2.3.0 :009 >
2.3.0 :010 > require 'money'
=> true
2.3.0 :011 > Money.add_rate("USD", "EUR", 0.5)
=> 0.5
2.3.0 :012 > Money.us_dollar(100).exchange_to("EUR").currency
=> #<Money::Currency id: eur, priority: 2, symbol_first: true, thousands_separator: ., html_entity: €, decimal_mark: ,, name: Euro, symbol: €, subunit_to_unit: 100, exponent: 2, iso_code: EUR, iso_numeric: 978, subunit: Cent, smallest_denomination: 1>
2.3.0 :013 >
2.3.0 :014 >