Note that there are some explanatory texts on larger screens.

plurals
  1. POLoadError in Users::OmniauthCallbacksController#facebook - Rails 4
    primarykey
    data
    text
    <p>well, I am trying to code a system that uses facebook login. When I click on the facebook link it goes to facebook page for authentication and on the callback show me this error: Unable to autoload constant Users::OmniauthCallbacksController, expected <em>path</em>/app/controllers/users/omniauth_callbacks_controller.rb to define it. I am using devise gem, omniauth gem, ruby 2 and rails 4.</p> <p>My <strong>user_controller.rb</strong></p> <pre><code>class User::OmniauthCallbacksController &lt; Devise::OmniauthCallbacksController def facebook @user = User.find_for_facebook_oauth(request.env['omniauth.auth'], current_user) if @user.persisted? sign_in_and_redirect @user, :event =&gt; :authentication #this will throw if @user is not activated set_flash_message(:notice, :success, :kind =&gt; 'Facebook') if is_navigational_format? else session['devise.facebook_data'] = request.env['omniauth.auth'] redirect_to new_user_registration_url end end end </code></pre> <p><strong>My user.rb</strong></p> <pre><code>class User &lt; ActiveRecord::Base devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable, :omniauthable def self.find_for_facebook_oauth(auth, signed_in_resource = nil) user = User.where(:provider =&gt; auth.provider, :uid =&gt; auth.uid).first if user return user else registered_user = User.where(:email =&gt; auth.info.email).first if registered_user return registered_user else user = User.create(name:auth.extra.raw_info.name, provider:auth.provider, uid:auth.uid, email:auth.info.email, password:Devise.friendly_token[0,20], ) end end end end </code></pre> <p>On <strong>routes.rb</strong> I have this line:</p> <pre><code>devise_for :users, :controllers =&gt; { :omniauth_callbacks =&gt; 'users/omniauth_callbacks' } </code></pre> <p>The Full Trace is this:</p> <pre><code>activesupport (4.0.0) lib/active_support/dependencies.rb:463:in `load_missing_constant' activesupport (4.0.0) lib/active_support/dependencies.rb:183:in `const_missing' activesupport (4.0.0) lib/active_support/inflector/methods.rb:228:in `const_get' activesupport (4.0.0) lib/active_support/inflector/methods.rb:228:in `block in constantize' activesupport (4.0.0) lib/active_support/inflector/methods.rb:224:in `each' activesupport (4.0.0) lib/active_support/inflector/methods.rb:224:in `inject' activesupport (4.0.0) lib/active_support/inflector/methods.rb:224:in `constantize' activesupport (4.0.0) lib/active_support/dependencies.rb:534:in `get' activesupport (4.0.0) lib/active_support/dependencies.rb:565:in `constantize' actionpack (4.0.0) lib/action_dispatch/routing/route_set.rb:76:in `controller_reference' actionpack (4.0.0) lib/action_dispatch/routing/route_set.rb:66:in `controller' actionpack (4.0.0) lib/action_dispatch/routing/route_set.rb:44:in `call' actionpack (4.0.0) lib/action_dispatch/routing/mapper.rb:44:in `call' actionpack (4.0.0) lib/action_dispatch/journey/router.rb:71:in `block in call' actionpack (4.0.0) lib/action_dispatch/journey/router.rb:59:in `each' actionpack (4.0.0) lib/action_dispatch/journey/router.rb:59:in `call' actionpack (4.0.0) lib/action_dispatch/routing/route_set.rb:655:in `call' omniauth (1.1.4) lib/omniauth/strategy.rb:184:in `call!' omniauth (1.1.4) lib/omniauth/strategy.rb:164:in `call' omniauth (1.1.4) lib/omniauth/strategy.rb:184:in `call!' omniauth (1.1.4) lib/omniauth/strategy.rb:164:in `call' omniauth (1.1.4) lib/omniauth/strategy.rb:401:in `call_app!' omniauth (1.1.4) lib/omniauth/strategy.rb:363:in `callback_phase' omniauth-oauth2 (1.1.1) lib/omniauth/strategies/oauth2.rb:77:in `callback_phase' omniauth (1.1.4) lib/omniauth/strategy.rb:226:in `callback_call' omniauth (1.1.4) lib/omniauth/strategy.rb:182:in `call!' omniauth (1.1.4) lib/omniauth/strategy.rb:164:in `call' warden (1.2.3) lib/warden/manager.rb:35:in `block in call' warden (1.2.3) lib/warden/manager.rb:34:in `catch' warden (1.2.3) lib/warden/manager.rb:34:in `call' rack (1.5.2) lib/rack/etag.rb:23:in `call' rack (1.5.2) lib/rack/conditionalget.rb:25:in `call' rack (1.5.2) lib/rack/head.rb:11:in `call' actionpack (4.0.0) lib/action_dispatch/middleware/params_parser.rb:27:in `call' actionpack (4.0.0) lib/action_dispatch/middleware/flash.rb:241:in `call' rack (1.5.2) lib/rack/session/abstract/id.rb:225:in `context' rack (1.5.2) lib/rack/session/abstract/id.rb:220:in `call' actionpack (4.0.0) lib/action_dispatch/middleware/cookies.rb:486:in `call' activerecord (4.0.0) lib/active_record/query_cache.rb:36:in `call' activerecord (4.0.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:626:in `call' activerecord (4.0.0) lib/active_record/migration.rb:369:in `call' actionpack (4.0.0) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call' activesupport (4.0.0) lib/active_support/callbacks.rb:373:in `_run__878755641__call__callbacks' activesupport (4.0.0) lib/active_support/callbacks.rb:80:in `run_callbacks' actionpack (4.0.0) lib/action_dispatch/middleware/callbacks.rb:27:in `call' actionpack (4.0.0) lib/action_dispatch/middleware/reloader.rb:64:in `call' actionpack (4.0.0) lib/action_dispatch/middleware/remote_ip.rb:76:in `call' actionpack (4.0.0) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call' actionpack (4.0.0) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call' railties (4.0.0) lib/rails/rack/logger.rb:38:in `call_app' railties (4.0.0) lib/rails/rack/logger.rb:21:in `block in call' activesupport (4.0.0) lib/active_support/tagged_logging.rb:67:in `block in tagged' activesupport (4.0.0) lib/active_support/tagged_logging.rb:25:in `tagged' activesupport (4.0.0) lib/active_support/tagged_logging.rb:67:in `tagged' railties (4.0.0) lib/rails/rack/logger.rb:21:in `call' actionpack (4.0.0) lib/action_dispatch/middleware/request_id.rb:21:in `call' rack (1.5.2) lib/rack/methodoverride.rb:21:in `call' rack (1.5.2) lib/rack/runtime.rb:17:in `call' activesupport (4.0.0) lib/active_support/cache/strategy/local_cache.rb:83:in `call' rack (1.5.2) lib/rack/lock.rb:17:in `call' actionpack (4.0.0) lib/action_dispatch/middleware/static.rb:64:in `call' railties (4.0.0) lib/rails/engine.rb:511:in `call' railties (4.0.0) lib/rails/application.rb:97:in `call' rack (1.5.2) lib/rack/lock.rb:17:in `call' rack (1.5.2) lib/rack/content_length.rb:14:in `call' rack (1.5.2) lib/rack/handler/webrick.rb:60:in `service' C:/Development/Ruby200/lib/ruby/2.0.0/webrick/httpserver.rb:138:in `service' C:/Development/Ruby200/lib/ruby/2.0.0/webrick/httpserver.rb:94:in `run' C:/Development/Ruby200/lib/ruby/2.0.0/webrick/server.rb:295:in `block in start_thread' </code></pre> <p>So that's my problem I hope someone can help me.</p> <p><strong>EDIT:</strong> rather than what I implied to, my callbacks controller is called omniauth_callbacks_controller.rb. 1. As <strong><em>sevenseacat</em></strong> suggested I changed the reference from <strong>users</strong> to <strong>user</strong> on my route file, but the problem still happened. 2. As <strong>*uno_ordinary*</strong> suggested I added <strong>:omniauth_providers => :facebook</strong> on my model but after that I received a new error when starting the server:</p> <pre><code>=&gt; Booting WEBrick =&gt; Rails 4.0.0 application starting in development on http://0.0.0.0:3000 =&gt; Run `rails server -h` for more startup options =&gt; Ctrl-C to shutdown server Exiting C:3:in `rescue in execute_if_updated': Rails::Application::RoutesReloader#execute_if_updated delegated to updater.execute_if_updated, but updater is nil: #&lt;Rails::Application::RoutesReloader:0x4375db8 @paths=["C:/Users/Diogo de Lima/Documents/Development/Ruby on Rails/Rhodnius/config/routes.rb"], @route_sets=[#&lt;ActionDispatch::Routing::RouteSet:0x449da98&gt;]&gt; (RuntimeError) from C:131071:in `execute_if_updated' from C:/Development/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/application/finisher.rb:69:in `block in &lt;module:Finisher&gt;' from C:/Development/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/initializable.rb:30:in `instance_exec' from C:/Development/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/initializable.rb:30:in `run' from C:/Development/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/initializable.rb:55:in `block in run_initializers' from C:/Development/Ruby200/lib/ruby/2.0.0/tsort.rb:150:in `block in tsort_each' from C:/Development/Ruby200/lib/ruby/2.0.0/tsort.rb:183:in `block (2 levels) in each_strongly_connected_component' from C:/Development/Ruby200/lib/ruby/2.0.0/tsort.rb:219:in `each_strongly_connected_component_from' from C:/Development/Ruby200/lib/ruby/2.0.0/tsort.rb:182:in `block in each_strongly_connected_component' from C:/Development/Ruby200/lib/ruby/2.0.0/tsort.rb:180:in `each' from C:/Development/Ruby200/lib/ruby/2.0.0/tsort.rb:180:in `each_strongly_connected_component' from C:/Development/Ruby200/lib/ruby/2.0.0/tsort.rb:148:in `tsort_each' from C:/Development/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/initializable.rb:54:in `run_initializers' from C:/Development/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/application.rb:215:in `initialize!' from C:/Development/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/railtie/configurable.rb:30:in `method_missing' from C:/Users/Diogo de Lima/Documents/Development/Ruby on Rails/Rhodnius/config/environment.rb:5:in `&lt;top (required)&gt;' from C:/Development/Ruby200/lib/ruby/gems/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require' from C:/Development/Ruby200/lib/ruby/gems/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `block in require' from C:/Development/Ruby200/lib/ruby/gems/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:213:in `load_dependency' from C:/Development/Ruby200/lib/ruby/gems/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require' from C:/Users/Diogo de Lima/Documents/Development/Ruby on Rails/Rhodnius/config.ru:3:in `block in &lt;main&gt;' from C:/Development/Ruby200/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:55:in `instance_eval' from C:/Development/Ruby200/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:55:in `initialize' from C:/Users/Diogo de Lima/Documents/Development/Ruby on Rails/Rhodnius/config.ru:in `new' from C:/Users/Diogo de Lima/Documents/Development/Ruby on Rails/Rhodnius/config.ru:in `&lt;main&gt;' from C:/Development/Ruby200/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:49:in `eval' from C:/Development/Ruby200/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:49:in `new_from_string' from C:/Development/Ruby200/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:40:in `parse_file' from C:/Development/Ruby200/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/server.rb:277:in `build_app_and_options_from_config' from C:/Development/Ruby200/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/server.rb:199:in `app' from C:/Development/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/commands/server.rb:48:in `app' from C:/Development/Ruby200/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/server.rb:314:in `wrapped_app' from C:/Development/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/commands/server.rb:75:in `start' from C:/Development/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/commands.rb:78:in `block in &lt;top (required)&gt;' from C:/Development/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/commands.rb:73:in `tap' from C:/Development/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/commands.rb:73:in `&lt;top (required)&gt;' from bin/rails:4:in `require' from bin/rails:4:in `&lt;main&gt;' </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload