gpt4 book ai didi

ruby-on-rails - 金钱::银行::GoogleCurrencyFetchError

转载 作者:太空宇宙 更新时间:2023-11-03 17:14:08 28 4
gpt4 key购买 nike

当我使用“exchange_to (: CLP) .to_i”方法时,它在 OrdersController#create 中给我错误 Money::Bank::GoogleCurrencyFetchError货币::银行::GoogleCurrencyFetchError

# class OrdersController < ApplicationController
def create
@buying_methods = Order.buying_methods.keys
@shipping_type_clients = Order.shipping_type_clients.keys
@order = Order.new(order_params)
@order.dollar = Money.new(100, "USD").exchange_to(:CLP).to_i
@order.user = current_user

respond_to do |format|
if @order.save
if @order.cmm_buy?
@order.in_draft!
end
format.html { redirect_to "#{my_account_path}#my-orders", notice: 'El pedido se ha creado con éxito.' }
else
@order.products.build
format.html { render :new }
end
end
end

# config/initializers/google_currency.rb
require 'money'
require 'money/bank/google_currency'

# seconds after than the current rates are automatically expired (24 hours)
Money::Bank::GoogleCurrency.ttl_in_seconds = 86400

# set default bank to instance of GoogleCurrency
Money.default_bank = Money::Bank::GoogleCurrency.new

# config/initializers/
MoneyRails.configure do |config|
config.register_currency = {
:iso_code => "US8",
:subunit_to_unit => 100_000_000,
:thousands_separator => ".",
:decimal_mark => ","
}
end

最佳答案

在你的文件中:

config/initializer/money.rb

在顶部添加这一行:

Money::Bank::GoogleCurrency::SERVICE_HOST="finance.google.com"

关于ruby-on-rails - 金钱::银行::GoogleCurrencyFetchError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46227559/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com