【发布时间】:2020-04-11 15:43:28
【问题描述】:
这是一个相当“新手”的问题,但我一直在搜索,似乎找不到任何东西可以解决在我的模型方法之一中使用 hyperclient 在 Rails 应用程序中的错误。
每当我运行rails c 时,我都会收到错误消息
NoMethodError (undefined method `new' for Hyperclient:Module)
在我的 gemfile
gem "hyperclient"
--跑bundle install
在模型中app/models/artwork.rb
class Artwork < ApplicationRecord
require "hyperclient"
def self.test_artsy
api = Hyperclient.new('https://api.artsy.net/api') do |api|
puts api
end
end
end
我查看了docs on hyperclient 并看到他们确实有一个 .new 的方法(也在他们的示例中)所以我知道这是我做错了,但我不确定还有什么可以尝试的?
在终端中打开 irb 时代码确实有效。
【问题讨论】: