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)

omn​​iauth-twitter gem (サーバーはそれで開始されます) を含めることもできますが、これがないと機能しない理由がわかりません。Railscast のレポをフォークしたとき、すべてが正常に機能したため、なぜこれが起こっているのかわかりません。omn​​iauth-twitter gem がインストールされているためだと思い (バンドルでは使用されていませんが)、アンインストールしましたが、機能しませんでした。

完全な Gemfile:

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-twitterにgem を追加する必要がありますGemfile

于 2012-06-16T21:00:52.320 に答える
0

私はここでパーティーに出遅れましたが、Railscasts のような ~> 0.3.0 バージョンではなく、最新バージョンの Omniauth > 1 を使用していたため、omniauth-twitter を求められていたと思います。

しかし、あなたはおそらくすでにそれを理解しています;)

于 2012-10-29T19:52:34.403 に答える