2017-10-21 13 views
0

私はその後、私はfacebook.rbを作成したコンフィグFacebookの認証、無方式[]エラー

development: 
app_id: 28679********* 
secret: ba02f0735cfdd4************ 

にファイルfacebook.ymlを作成した最初の、Facebookのアカウントを使用して私のウェブサイトにログインしたいです/設定/初期化子

FACEBOOK_CONFIG = YAML.load_file("#{::Rails.root}/config/facebook.yml")[::Rails.env] 

次で、私は

omniauth.rb と呼ばれる別のファイルを作ります私は何を実行した場合0
OmniAuth.config.logger = Rails.logger 
Rails.application.config.middleware.use OmniAuth::Builder do 
    provider :facebook, FACEBOOK_CONFIG['app_id'], FACEBOOK_CONFIG['secret'], {:scope => 'public_profile, email'},{:info_fields => 'id,first_name,middle_name,last_name,email,name,link'} 
end 

さて、それはuが私は方法は[] facebook.rbで、私は知りません作成したことを見ることができますが

rake aborted! 
NoMethodError: undefined method `[]' for nil:NilClass 
/home/van/FastMail/config/initializers/omniauth.rb:3:in `block in <top (required)>' 
/home/van/.rvm/gems/ruby-2.4.2/gems/rack-2.0.3/lib/rack/builder.rb:55:in `instance_eval' 
/home/van/.rvm/gems/ruby-2.4.2/gems/rack-2.0.3/lib/rack/builder.rb:55:in `initialize' 
/home/van/.rvm/gems/ruby-2.4.2/gems/omniauth-1.7.1/lib/omniauth/builder.rb:6:in `initialize' 
/home/van/.rvm/gems/ruby-2.4.2/gems/actionpack-5.1.4/lib/action_dispatch/middleware/stack.rb:35:in `new' 
/home/van/.rvm/gems/ruby-2.4.2/gems/actionpack-5.1.4/lib/action_dispatch/middleware/stack.rb:35:in `build' 
/home/van/.rvm/gems/ruby-2.4.2/gems/actionpack-5.1.4/lib/action_dispatch/middleware/stack.rb:99:in `block in build' 
/home/van/.rvm/gems/ruby-2.4.2/gems/actionpack-5.1.4/lib/action_dispatch/middleware/stack.rb:99:in `each' 
/home/van/.rvm/gems/ruby-2.4.2/gems/actionpack-5.1.4/lib/action_dispatch/middleware/stack.rb:99:in `inject' 
/home/van/.rvm/gems/ruby-2.4.2/gems/actionpack-5.1.4/lib/action_dispatch/middleware/stack.rb:99:in `build' 
/home/van/.rvm/gems/ruby-2.4.2/gems/railties-5.1.4/lib/rails/engine.rb:508:in `block in app' 
/home/van/.rvm/gems/ruby-2.4.2/gems/railties-5.1.4/lib/rails/engine.rb:504:in `synchronize' 
/home/van/.rvm/gems/ruby-2.4.2/gems/railties-5.1.4/lib/rails/engine.rb:504:in `app' 
/home/van/.rvm/gems/ruby-2.4.2/gems/railties-5.1.4/lib/rails/application/finisher.rb:45:in `block in <module:Finisher>' 
/home/van/.rvm/gems/ruby-2.4.2/gems/railties-5.1.4/lib/rails/initializable.rb:30:in `instance_exec' 
/home/van/.rvm/gems/ruby-2.4.2/gems/railties-5.1.4/lib/rails/initializable.rb:30:in `run' 
/home/van/.rvm/gems/ruby-2.4.2/gems/railties-5.1.4/lib/rails/initializable.rb:59:in `block in run_initializers' 
/home/van/.rvm/gems/ruby-2.4.2/gems/railties-5.1.4/lib/rails/initializable.rb:58:in `run_initializers' 
/home/van/.rvm/gems/ruby-2.4.2/gems/railties-5.1.4/lib/rails/application.rb:353:in `initialize!' 
/home/van/FastMail/config/environment.rb:5:in `<top (required)>' 
/home/van/.rvm/gems/ruby-2.4.2/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:in `require' 
/home/van/.rvm/gems/ruby-2.4.2/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:in `block in require' 
/home/van/.rvm/gems/ruby-2.4.2/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:258:in `load_dependency' 
/home/van/.rvm/gems/ruby-2.4.2/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:in `require' 
/home/van/.rvm/gems/ruby-2.4.2/gems/railties-5.1.4/lib/rails/application.rb:329:in `require_environment!' 
/home/van/.rvm/gems/ruby-2.4.2/gems/railties-5.1.4/lib/rails/application.rb:445:in `block in run_tasks_blocks' 
/home/van/.rvm/gems/ruby-2.4.2/gems/rake-12.1.0/exe/rake:27:in `<top (required)>' 
/home/van/.rvm/gems/ruby-2.4.2/bin/ruby_executable_hooks:15:in `eval' 
/home/van/.rvm/gems/ruby-2.4.2/bin/ruby_executable_hooks:15:in `<main>' 
Tasks: TOP => db:migrate => environment 
(See full trace by running task with --trace) 

ことを言い続け何

答えて

0

OK間違っています私は片方の方法を見つけただけで、omniauthファイルのFACEBOOK_CONFIGを削除し、app_idと秘密を直接入力します。