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 がインストールされているためだと思い (バンドルでは使用されていませんが)、アンインストールしましたが、機能しませんでした。
完全な 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>'
ありとあらゆる助けをいただければ幸いです。