未初始化的常量Instagram v2

时间:2014-06-23 14:36:22

标签: ruby-on-rails ruby ruby-on-rails-4 instagram

这个问题是Uninitialized constant Instagram的副本,但有一些不同的细节(因为没有人真正回答过最后一个问题)。我再次有一个使用Instagram API的网站。当我尝试运行rails server时(刚刚添加instagram gem时),我遇到了这样的错误:

NameError: uninitialized constant Instagram::Configuration::Faraday
/usr/local/rvm/gems/ruby-2.1.1/gems/instagram-1.0.0/lib/instagram/configuration.rb:29:in `<module:Configuration>'
/usr/local/rvm/gems/ruby-2.1.1/gems/instagram-1.0.0/lib/instagram/configuration.rb:6:in `<module:Instagram>'
/usr/local/rvm/gems/ruby-2.1.1/gems/instagram-1.0.0/lib/instagram/configuration.rb:4:in `<top (required)>'
/usr/local/rvm/gems/ruby-2.1.1/gems/instagram-1.0.0/lib/instagram.rb:2:in `require'
/usr/local/rvm/gems/ruby-2.1.1/gems/instagram-1.0.0/lib/instagram.rb:2:in `<top (required)>'
/usr/local/rvm/gems/ruby-2.1.1@global/gems/bundler-1.5.3/lib/bundler/runtime.rb:76:in `require'
/usr/local/rvm/gems/ruby-2.1.1@global/gems/bundler-1.5.3/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
/usr/local/rvm/gems/ruby-2.1.1@global/gems/bundler-1.5.3/lib/bundler/runtime.rb:72:in `each'
/usr/local/rvm/gems/ruby-2.1.1@global/gems/bundler-1.5.3/lib/bundler/runtime.rb:72:in `block in require'
/usr/local/rvm/gems/ruby-2.1.1@global/gems/bundler-1.5.3/lib/bundler/runtime.rb:61:in `each'
/usr/local/rvm/gems/ruby-2.1.1@global/gems/bundler-1.5.3/lib/bundler/runtime.rb:61:in `require'
/usr/local/rvm/gems/ruby-2.1.1@global/gems/bundler-1.5.3/lib/bundler.rb:131:in `require'
/vagrant/Documents/RubyProjects/instagram_example/config/application.rb:14:in `<top (required)>'
/vagrant/Documents/RubyProjects/instagram_example/Rakefile:4:in `<top (required)>'

这与上一个问题完全不同,因为我在gem中遇到错误。我试图用Instagram API克隆this example,但我得到了同样的错误。我的朋友试图运行这个例子,它适用于他。这是我的Gemfile

source 'https://rubygems.org'

gem 'rails', '4.1.1'
gem 'pg'
gem 'sass-rails', '~> 4.0.3'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'therubyracer',  platforms: :ruby
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'

gem 'sdoc', '~> 0.4.0',          group: :doc
gem 'spring',        group: :development
gem 'instagram'
gem 'dotenv-rails'

gem 'pry-rails', group: :development

这让我觉得到目前为止,我的Ubuntu 14.04工作得很糟糕。

解决方案: 使用安装在主机上的ruby,而不是在vagrant或其他虚拟机或虚拟机上。

1 个答案:

答案 0 :(得分:0)

添加

gem "instagram", "~> 1.1.1"

到Gemfile,然后:

  $ bundle install
  $ bundle exec rails c

然后在rails控制台类型

 Instagram

它应该总是返回类对象

编辑1:

不要忘记停止弹簧,然后将新宝石放入导轨项目

$ bin/spring stop