【问题标题】:Running API/gem on heroku gives Load error在 heroku 上运行 API/gem 会导致加载错误
【发布时间】:2017-06-21 20:29:31
【问题描述】:

我在我的 Ruby on Rails 应用程序中使用支付提供商 Mollie。它在本地工作,但不适用于 heroku。当我调用 API 时,它会给出错误:500:加载错误:无法加载此类文件 -- Mollie/Api/Client.有人知道如何在 heroku 上加载 API 吗?更新:我认为这与 heroku 保存宝石的位置有关。而且它找不到宝石的位置(??)

我通过运行在本地安装了 gem

$ gem install mollie-api-ruby

我还将 gem 添加到我的 gemfile 中(但不知道这是否有必要)。

gem 'mollie-api-ruby'

我在 Ruby on Rails 和 Heroku 方面没有经验,但我希望有人能提供一些技巧来使其正常工作。谢谢!


我通过以下方式在控制器中请求此 API:

def create

    @thrill = Thrill.find(params[:thrill_id])
    if @thrill.reservations.length < @thrill.training.tr_max_attendants
        @reservation = current_user.reservations.create(reservation_params)

        if @reservation

            require 'Mollie/API/Client'

            mollie = Mollie::API::Client.new('test_gUejkz43UkdeCauC22J6UNq')

            payment = mollie.payments.create(
                amount: @reservation.thrill.training.tr_price,
                description: @reservation.thrill.training.tr_name,
                redirect_Url: 'http://8a3a73cb.ngrok.io/your_trips',
                webhookUrl: 'http://8a3a73cb.ngrok.io/notify',
                metadata: {
                    reservationid: @reservation.id
                }
            )

            @reservation.update_attributes payid:payment.id
            redirect_to payment.payment_url

        else
            redirect_to @thrill.training, notice: "Helaas, de training is vol"
        end
    end
end

【问题讨论】:

  • 您肯定需要将 gem 添加到 Gemfile。同时在本地运行bundle,进行新的提交,然后将其推送到heroku。您也可以使用heroku run rails console 来检查您的应用环境
  • 感谢您的留言。在本地和 heroku bundle install 上都声明该应用程序正在“使用 mollie-api-ruby 2.0.1”,所以这对我来说似乎是正确的。这可能是我使用“需要'Mollie/API/Client'的方式吗?
  • 好的,找到答案了。它必须是小写的:需要'mollie/api/client'

标签: ruby-on-rails ruby heroku mollie


【解决方案1】:

好的,找到答案了。它必须是小写的:需要'mollie/api/client'

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-12-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多