我正在尝试在我的 Rails 应用程序中使用 Yelp API,但在这样做时遇到了麻烦。我正在关注此处的文档(https://github.com/Yelp/yelp-api/blob/master/v2/ruby/example.rb),但不断收到错误消息。下面是我在控制器中使用的代码:
require 'rubygems'
require 'oauth'
consumer_key = 'private'
consumer_secret = 'private'
token = 'private'
token_secret = 'private-private'
api_host = 'api.yelp.com'
@places = Place.all
consumer = OAuth::Consumer.new(consumer_key, consumer_secret, {:site => "http://#{api_host}"})
access_token = OAuth::AccessToken.new(consumer, token, token_secret)
path = "/v2/search?term=restaurants&location=new%20york"
p access_token.get(path).body
我不断收到的错误是:
cannot load such file -- oauth
我的 Gemfile 中有 gem 'omniauth' 并运行了 bundle install (以及重新启动服务器)但仍然收到此错误...有关如何解决此问题的任何想法?
宝石文件:
source 'https://rubygems.org'
gem 'rails', '3.2.12'
gem 'dynamic_form', '1.1.4'
gem 'sqlite3'
gem 'devise', '2.1.0rc'
gem 'bootstrap-sass', '2.1'
gem 'omniauth'
gem 'httparty'
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
group :test, :development do
gem 'rspec-rails', '~> 2.11'
end
group :test do
gem 'capybara', '1.1.2'
end