omn​​iauth facebook uninitialzed常量错误

时间:2016-08-12 07:00:58

标签: ruby-on-rails ruby omniauth-facebook

我正在关注rails cast视频here但是当我尝试运行我的服务器时,我收到错误"未初始化的常量OmniAuth(NameError)"。当我删除此文件时,服务器启动并显示主页,但Facebook登录验证的链接返回路由错误"没有路由匹配[GET]" / auth / facebook"当然。

我的问题类似于这个stackoverlfow问题here但是我的问题处于开发模式。

所有代码都是一样的我知道这是什么。请帮忙!

完整错误

C:/Sites/blog/config/initializers/omniauth.rb:1:in `<top (required)>': uninitialized constant OmniAuth (NameError)
    from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/railties-4.2.6/lib/rails/engine.rb:652:in `block in load_config_initializer'
    from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/activesupport-4.2.6/lib/active_support/notifications.rb:166:in `instrument'
    from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/railties-4.2.6/lib/rails/engine.rb:651:in `load_config_initializer'
    from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/railties-4.2.6/lib/rails/engine.rb:616:in `block (2 levels) in <class:Engine>'
    from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/railties-4.2.6/lib/rails/engine.rb:615:in `each'
    from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/railties-4.2.6/lib/rails/engine.rb:615:in `block in <class:Engine>'
    from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/railties-4.2.6/lib/rails/initializable.rb:30:in `instance_exec'
    from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/railties-4.2.6/lib/rails/initializable.rb:30:in `run'
    from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/railties-4.2.6/lib/rails/initializable.rb:55:in `block in run_initializers'
    from C:/RailsInstaller/Ruby2.2.0/lib/ruby/2.2.0/tsort.rb:226:in `block in tsort_each'
    from C:/RailsInstaller/Ruby2.2.0/lib/ruby/2.2.0/tsort.rb:348:in `block (2 levels) in each_strongly_connected_component'
    from C:/RailsInstaller/Ruby2.2.0/lib/ruby/2.2.0/tsort.rb:420:in `block (2 levels) in each_strongly_connected_component_from'
    from C:/RailsInstaller/Ruby2.2.0/lib/ruby/2.2.0/tsort.rb:429:in `each_strongly_connected_component_from'
    from C:/RailsInstaller/Ruby2.2.0/lib/ruby/2.2.0/tsort.rb:419:in `block in each_strongly_connected_component_from'
    from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/railties-4.2.6/lib/rails/initializable.rb:44:in `each'
    from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/railties-4.2.6/lib/rails/initializable.rb:44:in `tsort_each_child'
    from C:/RailsInstaller/Ruby2.2.0/lib/ruby/2.2.0/tsort.rb:413:in `call'
    from C:/RailsInstaller/Ruby2.2.0/lib/ruby/2.2.0/tsort.rb:413:in `each_strongly_connected_component_from'
    from C:/RailsInstaller/Ruby2.2.0/lib/ruby/2.2.0/tsort.rb:347:in `block in each_strongly_connected_component'
    from C:/RailsInstaller/Ruby2.2.0/lib/ruby/2.2.0/tsort.rb:345:in `each'
    from C:/RailsInstaller/Ruby2.2.0/lib/ruby/2.2.0/tsort.rb:345:in `call'
    from C:/RailsInstaller/Ruby2.2.0/lib/ruby/2.2.0/tsort.rb:345:in `each_strongly_connected_component'
    from C:/RailsInstaller/Ruby2.2.0/lib/ruby/2.2.0/tsort.rb:224:in `tsort_each'
    from C:/RailsInstaller/Ruby2.2.0/lib/ruby/2.2.0/tsort.rb:203:in `tsort_each'
    from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/railties-4.2.6/lib/rails/initializable.rb:54:in `run_initializers'
    from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/railties-4.2.6/lib/rails/application.rb:352:in `initialize!'
    from C:/Sites/blog/config/environment.rb:5:in `<top (required)>'
    from C:/Sites/blog/config.ru:3:in `require'
    from C:/Sites/blog/config.ru:3:in `block in <main>'
    from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/rack-1.6.4/lib/rack/builder.rb:55:in `instance_eval'
    from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/rack-1.6.4/lib/rack/builder.rb:55:in `initialize'
    from C:/Sites/blog/config.ru:in `new'
    from C:/Sites/blog/config.ru:in `<main>'
    from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/rack-1.6.4/lib/rack/builder.rb:49:in `eval'
    from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/rack-1.6.4/lib/rack/builder.rb:49:in `new_from_string'
    from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/rack-1.6.4/lib/rack/builder.rb:40:in `parse_file'
    from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/rack-1.6.4/lib/rack/server.rb:299:in `build_app_and_options_from_config'
    from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/rack-1.6.4/lib/rack/server.rb:208:in `app'
    from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/railties-4.2.6/lib/rails/commands/server.rb:61:in `app'
    from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/rack-1.6.4/lib/rack/server.rb:336:in `wrapped_app'
    from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/railties-4.2.6/lib/rails/commands/server.rb:139:in `log_to_stdout'
    from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/railties-4.2.6/lib/rails/commands/server.rb:78:in `start'
    from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:80:in `block in server'
    from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:75:in `tap'
    from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:75:in `server'
    from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
    from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/railties-4.2.6/lib/rails/commands.rb:17:in `<top (required)>'
    from bin/rails:4:in `require'
    from bin/rails:4:in `<main>'

此外,如果/initializers/omniauth.rb在其文件夹中,我无法生成用户模型,我需要删除它甚至这样做吗?

我安装了最新版本的omniauth-facebook gem并运行了bundle install。

1 个答案:

答案 0 :(得分:0)

你的gemfile中有omniauth和omniauth-facebook吗?像:

gem 'omniauth'
gem 'omniauth-facebook'