0

我正在尝试跟随 Railscasts #235(rails 应用程序中的 Omniauth)。

Rails (v3.2) 中的 Omniauth gem 遇到一些问题。当我在我的 Gemfile 中安装 gem 时,并在 omniauth.rb 中指定以下内容(在 config/initializers/ 中):

Rails.application.config.middleware.use OmniAuth::Builder do
  provider :twitter, '...', '...'
end

我似乎无法启动我的服务器 - 我收到以下错误:

/Users/tarunsachdeva/.rvm/gems/ruby-1.9.3-p0/gems/omniauth-1.1.0/lib/omniauth/builder.rb:38:in `rescue in provider': Could not find matching strategy for :twitter. You may need to install an additional gem (such as omniauth-twitter). (LoadError)

我可以包含omniauth-twitter gem(服务器以它开头),但我不知道为什么没有它就行不通。当我为 railscast 分叉存储库时,一切正常,所以不知道为什么会这样。我认为这是因为我安装了omniauth-twitter gem(虽然没有在捆绑包中使用),但我卸载了它,但没有奏效。

完整的宝石文件:

source 'https://rubygems.org'

gem 'rails', '3.2.2'
gem 'omniauth'
gem 'jquery-rails'
gem 'bootstrap-sass'
gem 'bcrypt-ruby'
gem 'redcarpet'

group :development, :test do
  gem 'pg', '0.12.2'
  gem 'rspec-rails', '2.9.0'
  gem 'annotate'
end

group :assets do
  gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'
  gem 'uglifier', '>= 1.0.3'
end

group :test do
  gem 'capybara', '1.1.2'
  gem 'factory_girl_rails', '1.4.0'
end

group :production do
  gem 'pg', '0.12.2'
end

下面的完整堆栈跟踪:

/Users/tarunsachdeva/.rvm/gems/ruby-1.9.3-p0/gems/omniauth-1.1.0/lib/omniauth/builder.rb:38:in `rescue in provider': Could not find matching strategy for :twitter. You may need to install an additional gem (such as omniauth-twitter). (LoadError)
    from /Users/tarunsachdeva/.rvm/gems/ruby-1.9.3-p0/gems/omniauth-1.1.0/lib/omniauth/builder.rb:35:in `provider'
    from /Users/tarunsachdeva/Development/rails/workbench/config/initializers/omniauth.rb:2:in `block in <top (required)>'
    from /Users/tarunsachdeva/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.1/lib/rack/builder.rb:51:in `instance_eval'
    from /Users/tarunsachdeva/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.1/lib/rack/builder.rb:51:in `initialize'
    from /Users/tarunsachdeva/.rvm/gems/ruby-1.9.3-p0/gems/omniauth-1.1.0/lib/omniauth/builder.rb:7:in `initialize'
    from /Users/tarunsachdeva/.rvm/gems/ruby-1.9.3-p0/gems/actionpack-3.2.2/lib/action_dispatch/middleware/stack.rb:43:in `new'
    from /Users/tarunsachdeva/.rvm/gems/ruby-1.9.3-p0/gems/actionpack-3.2.2/lib/action_dispatch/middleware/stack.rb:43:in `build'
    from /Users/tarunsachdeva/.rvm/gems/ruby-1.9.3-p0/gems/actionpack-3.2.2/lib/action_dispatch/middleware/stack.rb:113:in `block in build'
    from /Users/tarunsachdeva/.rvm/gems/ruby-1.9.3-p0/gems/actionpack-3.2.2/lib/action_dispatch/middleware/stack.rb:113:in `each'
    from /Users/tarunsachdeva/.rvm/gems/ruby-1.9.3-p0/gems/actionpack-3.2.2/lib/action_dispatch/middleware/stack.rb:113:in `inject'
    from /Users/tarunsachdeva/.rvm/gems/ruby-1.9.3-p0/gems/actionpack-3.2.2/lib/action_dispatch/middleware/stack.rb:113:in `build'
    from /Users/tarunsachdeva/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.2/lib/rails/engine.rb:470:in `app'
    from /Users/tarunsachdeva/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.2/lib/rails/application/finisher.rb:31:in `block in <module:Finisher>'
    from /Users/tarunsachdeva/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.2/lib/rails/initializable.rb:30:in `instance_exec'
    from /Users/tarunsachdeva/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.2/lib/rails/initializable.rb:30:in `run'
    from /Users/tarunsachdeva/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.2/lib/rails/initializable.rb:55:in `block in run_initializers'
    from /Users/tarunsachdeva/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.2/lib/rails/initializable.rb:54:in `each'
    from /Users/tarunsachdeva/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.2/lib/rails/initializable.rb:54:in `run_initializers'
    from /Users/tarunsachdeva/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.2/lib/rails/application.rb:136:in `initialize!'
    from /Users/tarunsachdeva/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.2/lib/rails/railtie/configurable.rb:30:in `method_missing'
    from /Users/tarunsachdeva/Development/rails/workbench/config/environment.rb:5:in `<top (required)>'
    from /Users/tarunsachdeva/Development/rails/workbench/config.ru:4:in `require'
    from /Users/tarunsachdeva/Development/rails/workbench/config.ru:4:in `block in <main>'
    from /Users/tarunsachdeva/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.1/lib/rack/builder.rb:51:in `instance_eval'
    from /Users/tarunsachdeva/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.1/lib/rack/builder.rb:51:in `initialize'
    from /Users/tarunsachdeva/Development/rails/workbench/config.ru:1:in `new'
    from /Users/tarunsachdeva/Development/rails/workbench/config.ru:1:in `<main>'
    from /Users/tarunsachdeva/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.1/lib/rack/builder.rb:40:in `eval'
    from /Users/tarunsachdeva/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.1/lib/rack/builder.rb:40:in `parse_file'
    from /Users/tarunsachdeva/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.1/lib/rack/server.rb:200:in `app'
    from /Users/tarunsachdeva/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.2/lib/rails/commands/server.rb:46:in `app'
    from /Users/tarunsachdeva/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.1/lib/rack/server.rb:301:in `wrapped_app'
    from /Users/tarunsachdeva/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.1/lib/rack/server.rb:252:in `start'
    from /Users/tarunsachdeva/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.2/lib/rails/commands/server.rb:70:in `start'
    from /Users/tarunsachdeva/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.2/lib/rails/commands.rb:55:in `block in <top (required)>'
    from /Users/tarunsachdeva/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.2/lib/rails/commands.rb:50:in `tap'
    from /Users/tarunsachdeva/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.2/lib/rails/commands.rb:50:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

任何和所有的帮助表示赞赏。

4

2 回答 2

4

阅读错误信息。您需要将omniauth-twittergem 添加到Gemfile.

于 2012-06-16T21:00:52.320 回答
0

我在这里参加聚会很时髦,但我认为您被要求使用omniauth-twitter,因为您使用的是最新版本的Omniauth > 1,而不是Railscasts 中的〜> 0.3.0 版本。

但你可能已经想通了;)

于 2012-10-29T19:52:34.403 回答