cbeer / devise-guests

fake 'em until you make 'em
MIT License
130 stars 31 forks source link

undefined method `_run_logging_in_user_callbacks' #17

Closed LimeBlast closed 3 years ago

LimeBlast commented 9 years ago

I'm using this gem on a project and have run into a problem.

I'm using Pundit, and after following their suggestion for passing a user into the config (https://github.com/elabs/pundit#customize-pundit-user) I'm now getting the following error the current_or_guest_user method is called via it:

undefined method `_run_logging_in_user_callbacks'

I think something weird is happening in the gem to cause this error.

jcoyne commented 9 years ago

@LimeBlast can you post a full stack trace?

LimeBlast commented 9 years ago

I got this from the rails s console, I hope it's what you need.

  Completed 500 Internal Server Error in 12ms

  NoMethodError - undefined method `_run_logging_in_user_callbacks' for #<ChaptersController:0x007f898223a588>:
    activesupport (4.2.0) lib/active_support/callbacks.rb:81:in `run_callbacks'
    /usr/local/Cellar/rbenv/0.4.0/versions/2.2.0/lib/ruby/gems/2.2.0/gems/devise-guests-0.3.3/lib/devise-guests/controllers/helpers.rb:52:in `current_or_guest_user'
    app/controllers/application_controller.rb:30:in `pundit_user'
    pundit (0.3.0) lib/pundit.rb:87:in `policy'
    pundit (0.3.0) lib/pundit.rb:69:in `authorize'
    app/controllers/chapters_controller.rb:14:in `new'
    actionpack (4.2.0) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
    actionpack (4.2.0) lib/abstract_controller/base.rb:198:in `process_action'
    actionpack (4.2.0) lib/action_controller/metal/rendering.rb:10:in `process_action'
    actionpack (4.2.0) lib/abstract_controller/callbacks.rb:20:in `block in process_action'
    activesupport (4.2.0) lib/active_support/callbacks.rb:117:in `call'
    activesupport (4.2.0) lib/active_support/callbacks.rb:151:in `block in halting_and_conditional'
    activesupport (4.2.0) lib/active_support/callbacks.rb:151:in `block in halting_and_conditional'
    activesupport (4.2.0) lib/active_support/callbacks.rb:151:in `block in halting_and_conditional'
    activesupport (4.2.0) lib/active_support/callbacks.rb:151:in `block in halting_and_conditional'
    activesupport (4.2.0) lib/active_support/callbacks.rb:234:in `block in halting'
    activesupport (4.2.0) lib/active_support/callbacks.rb:234:in `block in halting'
    activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `block in halting'
    activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `block in halting'
    activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `block in halting'
    activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `block in halting'
    activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `block in halting'
    activesupport (4.2.0) lib/active_support/callbacks.rb:234:in `block in halting'
    activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `block in halting'
    activesupport (4.2.0) lib/active_support/callbacks.rb:92:in `_run_callbacks'
    activesupport (4.2.0) lib/active_support/callbacks.rb:734:in `_run_process_action_callbacks'
    activesupport (4.2.0) lib/active_support/callbacks.rb:81:in `run_callbacks'
    actionpack (4.2.0) lib/abstract_controller/callbacks.rb:19:in `process_action'
    actionpack (4.2.0) lib/action_controller/metal/rescue.rb:29:in `process_action'
    actionpack (4.2.0) lib/action_controller/metal/instrumentation.rb:31:in `block in process_action'
    activesupport (4.2.0) lib/active_support/notifications.rb:164:in `block in instrument'
    activesupport (4.2.0) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
    activesupport (4.2.0) lib/active_support/notifications.rb:164:in `instrument'
    actionpack (4.2.0) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
    actionpack (4.2.0) lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
    activerecord (4.2.0) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
    actionpack (4.2.0) lib/abstract_controller/base.rb:137:in `process'
    actionview (4.2.0) lib/action_view/rendering.rb:30:in `process'
    actionpack (4.2.0) lib/action_controller/metal.rb:195:in `dispatch'
    actionpack (4.2.0) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
    actionpack (4.2.0) lib/action_controller/metal.rb:236:in `block in action'
    actionpack (4.2.0) lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
    actionpack (4.2.0) lib/action_dispatch/routing/route_set.rb:42:in `serve'
    actionpack (4.2.0) lib/action_dispatch/journey/router.rb:43:in `block in serve'
    actionpack (4.2.0) lib/action_dispatch/journey/router.rb:30:in `serve'
    actionpack (4.2.0) lib/action_dispatch/routing/route_set.rb:802:in `call'
    bullet (4.14.0) lib/bullet/rack.rb:12:in `call'
    meta_request (0.3.4) lib/meta_request/middlewares/app_request_handler.rb:13:in `call'
    meta_request (0.3.4) lib/meta_request/middlewares/meta_request_handler.rb:13:in `call'
    rack-livereload (0.3.15) lib/rack/livereload.rb:23:in `_call'
    rack-livereload (0.3.15) lib/rack/livereload.rb:14: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 `call'
    rack (1.6.0) lib/rack/etag.rb:24:in `call'
    rack (1.6.0) lib/rack/conditionalget.rb:25:in `call'
    rack (1.6.0) lib/rack/head.rb:13:in `call'
    actionpack (4.2.0) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
    actionpack (4.2.0) lib/action_dispatch/middleware/flash.rb:260:in `call'
    rack (1.6.0) lib/rack/session/abstract/id.rb:225:in `context'
    rack (1.6.0) lib/rack/session/abstract/id.rb:220:in `call'
    actionpack (4.2.0) lib/action_dispatch/middleware/cookies.rb:560:in `call'
    activerecord (4.2.0) lib/active_record/query_cache.rb:36:in `call'
    activerecord (4.2.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:647:in `call'
    activerecord (4.2.0) lib/active_record/migration.rb:378:in `call'
    actionpack (4.2.0) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
    activesupport (4.2.0) lib/active_support/callbacks.rb:88:in `_run_callbacks'
    activesupport (4.2.0) lib/active_support/callbacks.rb:734:in `_run_call_callbacks'
    activesupport (4.2.0) lib/active_support/callbacks.rb:81:in `run_callbacks'
    actionpack (4.2.0) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
    actionpack (4.2.0) lib/action_dispatch/middleware/reloader.rb:73:in `call'
    actionpack (4.2.0) lib/action_dispatch/middleware/remote_ip.rb:78:in `call'
    rack-contrib (1.2.0) lib/rack/contrib/response_headers.rb:17:in `call'
    meta_request (0.3.4) lib/meta_request/middlewares/headers.rb:16:in `call'
    better_errors (2.1.1) lib/better_errors/middleware.rb:84:in `protected_app_call'
    better_errors (2.1.1) lib/better_errors/middleware.rb:79:in `better_errors_call'
    better_errors (2.1.1) lib/better_errors/middleware.rb:57:in `call'
    web-console (2.0.0) lib/action_dispatch/debug_exceptions.rb:18:in `middleware_call'
    web-console (2.0.0) lib/action_dispatch/debug_exceptions.rb:13:in `call'
    actionpack (4.2.0) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
    railties (4.2.0) lib/rails/rack/logger.rb:38:in `call_app'
    railties (4.2.0) lib/rails/rack/logger.rb:20:in `block in call'
    activesupport (4.2.0) lib/active_support/tagged_logging.rb:68:in `block in tagged'
    activesupport (4.2.0) lib/active_support/tagged_logging.rb:26:in `tagged'
    activesupport (4.2.0) lib/active_support/tagged_logging.rb:68:in `tagged'
    railties (4.2.0) lib/rails/rack/logger.rb:20:in `call'
    actionpack (4.2.0) lib/action_dispatch/middleware/request_id.rb:21:in `call'
    rack (1.6.0) lib/rack/methodoverride.rb:22:in `call'
    rack (1.6.0) lib/rack/runtime.rb:18:in `call'
    activesupport (4.2.0) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
    rack (1.6.0) lib/rack/lock.rb:17:in `call'
    actionpack (4.2.0) lib/action_dispatch/middleware/static.rb:113:in `call'
    rack (1.6.0) lib/rack/sendfile.rb:113:in `call'
    railties (4.2.0) lib/rails/engine.rb:518:in `call'
    railties (4.2.0) lib/rails/application.rb:164:in `call'
    rack (1.6.0) lib/rack/lock.rb:17:in `call'
    rack (1.6.0) lib/rack/content_length.rb:15:in `call'
    rack (1.6.0) lib/rack/handler/webrick.rb:89:in `service'
    /usr/local/opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/webrick/httpserver.rb:138:in `service'
    /usr/local/opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/webrick/httpserver.rb:94:in `run'
    /usr/local/opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/webrick/server.rb:294:in `block in start_thread'
jcoyne commented 9 years ago

I can't make any sense out of it. The callbacks are defined here: https://github.com/cbeer/devise-guests/blob/577760bd35300623dd03086e988590d6d342b05b/lib/devise-guests/controllers/helpers.rb#L29 and called here: https://github.com/cbeer/devise-guests/blob/577760bd35300623dd03086e988590d6d342b05b/lib/devise-guests/controllers/helpers.rb#L52

So, it's not clear why they shouldn't be defined. Maybe Pundit messes with how devise includes helpers?

LimeBlast commented 9 years ago

I don't know if this will help or not, but I only get the problem when I'm logged in. I also get the problem outside of pundit, such as calling it from a the controller. One last thing, I can avoid the problem if I create a _run_logging_in_user_callbacks on the controller... but I feel this is side stepping the problem, not fixing it.

This is the stack trace when I run it from another controller:

Completed 500 Internal Server Error in 9ms

NoMethodError - undefined method `_run_logging_in_user_callbacks' for #<StaticPagesController:0x007f8983ac1520>:
  activesupport (4.2.0) lib/active_support/callbacks.rb:81:in `run_callbacks'
  /usr/local/Cellar/rbenv/0.4.0/versions/2.2.0/lib/ruby/gems/2.2.0/gems/devise-guests-0.3.3/lib/devise-guests/controllers/helpers.rb:52:in `current_or_guest_user'
  app/controllers/static_pages_controller.rb:3:in `home'
  actionpack (4.2.0) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
  actionpack (4.2.0) lib/abstract_controller/base.rb:198:in `process_action'
  actionpack (4.2.0) lib/action_controller/metal/rendering.rb:10:in `process_action'
  actionpack (4.2.0) lib/abstract_controller/callbacks.rb:20:in `block in process_action'
  activesupport (4.2.0) lib/active_support/callbacks.rb:117:in `call'
  activesupport (4.2.0) lib/active_support/callbacks.rb:151:in `block in halting_and_conditional'
  activesupport (4.2.0) lib/active_support/callbacks.rb:234:in `block in halting'
  activesupport (4.2.0) lib/active_support/callbacks.rb:234:in `block in halting'
  activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `block in halting'
  activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `block in halting'
  activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `block in halting'
  activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `block in halting'
  activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `block in halting'
  activesupport (4.2.0) lib/active_support/callbacks.rb:234:in `block in halting'
  activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `block in halting'
  activesupport (4.2.0) lib/active_support/callbacks.rb:92:in `_run_callbacks'
  activesupport (4.2.0) lib/active_support/callbacks.rb:734:in `_run_process_action_callbacks'
  activesupport (4.2.0) lib/active_support/callbacks.rb:81:in `run_callbacks'
  actionpack (4.2.0) lib/abstract_controller/callbacks.rb:19:in `process_action'
  actionpack (4.2.0) lib/action_controller/metal/rescue.rb:29:in `process_action'
  actionpack (4.2.0) lib/action_controller/metal/instrumentation.rb:31:in `block in process_action'
  activesupport (4.2.0) lib/active_support/notifications.rb:164:in `block in instrument'
  activesupport (4.2.0) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
  activesupport (4.2.0) lib/active_support/notifications.rb:164:in `instrument'
  actionpack (4.2.0) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
  actionpack (4.2.0) lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
  activerecord (4.2.0) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
  actionpack (4.2.0) lib/abstract_controller/base.rb:137:in `process'
  actionview (4.2.0) lib/action_view/rendering.rb:30:in `process'
  actionpack (4.2.0) lib/action_controller/metal.rb:195:in `dispatch'
  actionpack (4.2.0) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
  actionpack (4.2.0) lib/action_controller/metal.rb:236:in `block in action'
  actionpack (4.2.0) lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
  actionpack (4.2.0) lib/action_dispatch/routing/route_set.rb:42:in `serve'
  actionpack (4.2.0) lib/action_dispatch/journey/router.rb:43:in `block in serve'
  actionpack (4.2.0) lib/action_dispatch/journey/router.rb:30:in `serve'
  actionpack (4.2.0) lib/action_dispatch/routing/route_set.rb:802:in `call'
  bullet (4.14.0) lib/bullet/rack.rb:12:in `call'
  meta_request (0.3.4) lib/meta_request/middlewares/app_request_handler.rb:13:in `call'
  meta_request (0.3.4) lib/meta_request/middlewares/meta_request_handler.rb:13:in `call'
  rack-livereload (0.3.15) lib/rack/livereload.rb:23:in `_call'
  rack-livereload (0.3.15) lib/rack/livereload.rb:14: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 `call'
  rack (1.6.0) lib/rack/etag.rb:24:in `call'
  rack (1.6.0) lib/rack/conditionalget.rb:25:in `call'
  rack (1.6.0) lib/rack/head.rb:13:in `call'
  actionpack (4.2.0) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
  actionpack (4.2.0) lib/action_dispatch/middleware/flash.rb:260:in `call'
  rack (1.6.0) lib/rack/session/abstract/id.rb:225:in `context'
  rack (1.6.0) lib/rack/session/abstract/id.rb:220:in `call'
  actionpack (4.2.0) lib/action_dispatch/middleware/cookies.rb:560:in `call'
  activerecord (4.2.0) lib/active_record/query_cache.rb:36:in `call'
  activerecord (4.2.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:647:in `call'
  activerecord (4.2.0) lib/active_record/migration.rb:378:in `call'
  actionpack (4.2.0) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
  activesupport (4.2.0) lib/active_support/callbacks.rb:88:in `_run_callbacks'
  activesupport (4.2.0) lib/active_support/callbacks.rb:734:in `_run_call_callbacks'
  activesupport (4.2.0) lib/active_support/callbacks.rb:81:in `run_callbacks'
  actionpack (4.2.0) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
  actionpack (4.2.0) lib/action_dispatch/middleware/reloader.rb:73:in `call'
  actionpack (4.2.0) lib/action_dispatch/middleware/remote_ip.rb:78:in `call'
  rack-contrib (1.2.0) lib/rack/contrib/response_headers.rb:17:in `call'
  meta_request (0.3.4) lib/meta_request/middlewares/headers.rb:16:in `call'
  better_errors (2.1.1) lib/better_errors/middleware.rb:84:in `protected_app_call'
  better_errors (2.1.1) lib/better_errors/middleware.rb:79:in `better_errors_call'
  better_errors (2.1.1) lib/better_errors/middleware.rb:57:in `call'
  web-console (2.0.0) lib/action_dispatch/debug_exceptions.rb:18:in `middleware_call'
  web-console (2.0.0) lib/action_dispatch/debug_exceptions.rb:13:in `call'
  actionpack (4.2.0) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
  railties (4.2.0) lib/rails/rack/logger.rb:38:in `call_app'
  railties (4.2.0) lib/rails/rack/logger.rb:20:in `block in call'
  activesupport (4.2.0) lib/active_support/tagged_logging.rb:68:in `block in tagged'
  activesupport (4.2.0) lib/active_support/tagged_logging.rb:26:in `tagged'
  activesupport (4.2.0) lib/active_support/tagged_logging.rb:68:in `tagged'
  railties (4.2.0) lib/rails/rack/logger.rb:20:in `call'
  actionpack (4.2.0) lib/action_dispatch/middleware/request_id.rb:21:in `call'
  rack (1.6.0) lib/rack/methodoverride.rb:22:in `call'
  rack (1.6.0) lib/rack/runtime.rb:18:in `call'
  activesupport (4.2.0) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
  rack (1.6.0) lib/rack/lock.rb:17:in `call'
  actionpack (4.2.0) lib/action_dispatch/middleware/static.rb:113:in `call'
  rack (1.6.0) lib/rack/sendfile.rb:113:in `call'
  railties (4.2.0) lib/rails/engine.rb:518:in `call'
  railties (4.2.0) lib/rails/application.rb:164:in `call'
  rack (1.6.0) lib/rack/lock.rb:17:in `call'
  rack (1.6.0) lib/rack/content_length.rb:15:in `call'
  rack (1.6.0) lib/rack/handler/webrick.rb:89:in `service'
  /usr/local/opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/webrick/httpserver.rb:138:in `service'
  /usr/local/opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/webrick/httpserver.rb:94:in `run'
  /usr/local/opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/webrick/server.rb:294:in `block in start_thread'
LimeBlast commented 9 years ago

One last bit of info - this only happens when I call current_or_guest_user from the controller. Doing the same from the view works fine.

ssoulless commented 9 years ago

Im having a similar issue with omnioauth-facebook https://github.com/cbeer/devise-guests/issues/18

but in my case it fails even in the views...

This is a bug of the gem.

finalarena commented 9 years ago

same issue. Calling current_user directly is fine.

RSSchermer commented 9 years ago

Any news on this? Any of you happen to stumble upon a workaround?

TSMMark commented 8 years ago

I'm getting this as well.

NoMethodError - undefined method `_run_logging_in_user_callbacks' for #<DecksController:0x007f179c3a0a88>:
activesupport (4.2.5.2) lib/active_support/callbacks.rb:81:in `run_callbacks'
devise-guests (0.5.0) lib/devise-guests/controllers/helpers.rb:52:in `current_or_guest_user'
actionpack (4.2.5.2) lib/abstract_controller/helpers.rb:67:in `current_or_guest_user'
app/views/layouts/application.html.erb:24:in `_app_views_layouts_application_html_erb__3434003585745800402_69869695105520'
actionview (4.2.5.2) lib/action_view/template.rb:145:in `block in render'
activesupport (4.2.5.2) lib/active_support/notifications.rb:166:in `instrument'
actionview (4.2.5.2) lib/action_view/template.rb:333:in `instrument'
actionview (4.2.5.2) lib/action_view/template.rb:143:in `render'
actionview (4.2.5.2) lib/action_view/renderer/template_renderer.rb:66:in `render_with_layout'
skylight (0.10.3) lib/skylight/probes/action_view.rb:32:in `block in render_with_layout'
actionview (4.2.5.2) lib/action_view/renderer/abstract_renderer.rb:39:in `block in instrument'
activesupport (4.2.5.2) lib/active_support/notifications.rb:164:in `block in instrument'
activesupport (4.2.5.2) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.2.5.2) lib/active_support/notifications.rb:164:in `instrument'
actionview (4.2.5.2) lib/action_view/renderer/abstract_renderer.rb:39:in `instrument'
skylight (0.10.3) lib/skylight/probes/action_view.rb:31:in `render_with_layout'
actionview (4.2.5.2) lib/action_view/renderer/template_renderer.rb:52:in `render_template'
actionview (4.2.5.2) lib/action_view/renderer/template_renderer.rb:14:in `render'
actionview (4.2.5.2) lib/action_view/renderer/renderer.rb:46:in `render_template'
actionview (4.2.5.2) lib/action_view/renderer/renderer.rb:27:in `render'
actionview (4.2.5.2) lib/action_view/rendering.rb:100:in `_render_template'
actionpack (4.2.5.2) lib/action_controller/metal/streaming.rb:217:in `_render_template'
actionview (4.2.5.2) lib/action_view/rendering.rb:83:in `render_to_body'
actionpack (4.2.5.2) lib/action_controller/metal/rendering.rb:32:in `render_to_body'
actionpack (4.2.5.2) lib/action_controller/metal/renderers.rb:37:in `render_to_body'
actionpack (4.2.5.2) lib/abstract_controller/rendering.rb:25:in `render'
actionpack (4.2.5.2) lib/action_controller/metal/rendering.rb:16:in `render'
actionpack (4.2.5.2) lib/action_controller/metal/instrumentation.rb:44:in `block (2 levels) in render'
activesupport (4.2.5.2) lib/active_support/core_ext/benchmark.rb:12:in `block in ms'
/usr/lib/ruby/2.2.0/benchmark.rb:303:in `realtime'
activesupport (4.2.5.2) lib/active_support/core_ext/benchmark.rb:12:in `ms'
actionpack (4.2.5.2) lib/action_controller/metal/instrumentation.rb:44:in `block in render'
actionpack (4.2.5.2) lib/action_controller/metal/instrumentation.rb:87:in `cleanup_view_runtime'
activerecord (4.2.5.2) lib/active_record/railties/controller_runtime.rb:25:in `cleanup_view_runtime'
actionpack (4.2.5.2) lib/action_controller/metal/instrumentation.rb:43:in `render'
meta-tags (2.1.0) lib/meta_tags/controller_helper.rb:26:in `render_with_meta_tags'
actionpack (4.2.5.2) lib/action_controller/metal/implicit_render.rb:10:in `default_render'
actionpack (4.2.5.2) lib/action_controller/metal/implicit_render.rb:5:in `send_action'
actionpack (4.2.5.2) lib/abstract_controller/base.rb:198:in `process_action'
actionpack (4.2.5.2) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (4.2.5.2) lib/abstract_controller/callbacks.rb:20:in `block in process_action'
activesupport (4.2.5.2) lib/active_support/callbacks.rb:117:in `call'
activesupport (4.2.5.2) lib/active_support/callbacks.rb:555:in `block (2 levels) in compile'
activesupport (4.2.5.2) lib/active_support/callbacks.rb:505:in `call'
activesupport (4.2.5.2) lib/active_support/callbacks.rb:92:in `__run_callbacks__'
activesupport (4.2.5.2) lib/active_support/callbacks.rb:778:in `_run_process_action_callbacks'
activesupport (4.2.5.2) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (4.2.5.2) lib/abstract_controller/callbacks.rb:19:in `process_action'
actionpack (4.2.5.2) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (4.2.5.2) lib/action_controller/metal/instrumentation.rb:32:in `block in process_action'
activesupport (4.2.5.2) lib/active_support/notifications.rb:164:in `block in instrument'
activesupport (4.2.5.2) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.2.5.2) lib/active_support/notifications.rb:164:in `instrument'
actionpack (4.2.5.2) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
actionpack (4.2.5.2) lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
activerecord (4.2.5.2) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (4.2.5.2) lib/abstract_controller/base.rb:137:in `process'
actionview (4.2.5.2) lib/action_view/rendering.rb:30:in `process'
actionpack (4.2.5.2) lib/action_controller/metal.rb:196:in `dispatch'
actionpack (4.2.5.2) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
actionpack (4.2.5.2) lib/action_controller/metal.rb:237:in `block in action'
actionpack (4.2.5.2) lib/action_dispatch/routing/route_set.rb:74:in `dispatch'
actionpack (4.2.5.2) lib/action_dispatch/routing/route_set.rb:43:in `serve'
actionpack (4.2.5.2) lib/action_dispatch/journey/router.rb:43:in `block in serve'
actionpack (4.2.5.2) lib/action_dispatch/journey/router.rb:30:in `serve'
actionpack (4.2.5.2) lib/action_dispatch/routing/route_set.rb:815:in `call'
warden (1.2.6) lib/warden/manager.rb:35:in `block in call'
warden (1.2.6) lib/warden/manager.rb:34:in `call'
rack (1.6.4) lib/rack/etag.rb:24:in `call'
rack (1.6.4) lib/rack/conditionalget.rb:25:in `call'
rack (1.6.4) lib/rack/head.rb:13:in `call'
actionpack (4.2.5.2) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
actionpack (4.2.5.2) lib/action_dispatch/middleware/flash.rb:260:in `call'
rack (1.6.4) lib/rack/session/abstract/id.rb:225:in `context'
rack (1.6.4) lib/rack/session/abstract/id.rb:220:in `call'
actionpack (4.2.5.2) lib/action_dispatch/middleware/cookies.rb:560:in `call'
activerecord (4.2.5.2) lib/active_record/query_cache.rb:36:in `call'
activerecord (4.2.5.2) lib/active_record/connection_adapters/abstract/connection_pool.rb:653:in `call'
activerecord (4.2.5.2) lib/active_record/migration.rb:377:in `call'
actionpack (4.2.5.2) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.2.5.2) lib/active_support/callbacks.rb:88:in `__run_callbacks__'
activesupport (4.2.5.2) lib/active_support/callbacks.rb:778:in `_run_call_callbacks'
activesupport (4.2.5.2) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (4.2.5.2) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (4.2.5.2) lib/action_dispatch/middleware/reloader.rb:73:in `call'
actionpack (4.2.5.2) lib/action_dispatch/middleware/remote_ip.rb:78:in `call'
better_errors (2.1.1) lib/better_errors/middleware.rb:84:in `protected_app_call'
better_errors (2.1.1) lib/better_errors/middleware.rb:79:in `better_errors_call'
better_errors (2.1.1) lib/better_errors/middleware.rb:57:in `call'
actionpack (4.2.5.2) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
web-console (2.3.0) lib/web_console/middleware.rb:20:in `block in call'
web-console (2.3.0) lib/web_console/middleware.rb:18:in `call'
actionpack (4.2.5.2) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.2.5.2) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.2.5.2) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.2.5.2) lib/active_support/tagged_logging.rb:68:in `block in tagged'
activesupport (4.2.5.2) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (4.2.5.2) lib/active_support/tagged_logging.rb:68:in `tagged'
railties (4.2.5.2) lib/rails/rack/logger.rb:20:in `call'
actionpack (4.2.5.2) lib/action_dispatch/middleware/request_id.rb:21:in `call'
rack (1.6.4) lib/rack/methodoverride.rb:22:in `call'
rack (1.6.4) lib/rack/runtime.rb:18:in `call'
activesupport (4.2.5.2) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
rack (1.6.4) lib/rack/lock.rb:17:in `call'
actionpack (4.2.5.2) lib/action_dispatch/middleware/static.rb:116:in `call'
rack (1.6.4) lib/rack/sendfile.rb:113:in `call'
railties (4.2.5.2) lib/rails/engine.rb:518:in `call'
railties (4.2.5.2) lib/rails/application.rb:165:in `call'
rack (1.6.4) lib/rack/content_length.rb:15:in `call'
puma (3.2.0) lib/puma/configuration.rb:227:in `call'
puma (3.2.0) lib/puma/server.rb:561:in `handle_request'
puma (3.2.0) lib/puma/server.rb:406:in `process_client'
puma (3.2.0) lib/puma/server.rb:271:in `block in run'
puma (3.2.0) lib/puma/thread_pool.rb:111:in `block in spawn_thread'
fippu82 commented 8 years ago

Same issue now here when I do

if current_or_guest_user.admin?

in a view. I'm on version 4.2.0.

As a workaround, I do:

if current_user.blank? current_or_guest_user.admin? else current_user.admin? end

It is ugly, because obviously the main point of having the current_or_guest_user method is to avoid this.... :-(

lacostenycoder commented 7 years ago

I'm getting the same error, had to downgrade to version 0.4.0

christopherdbull commented 6 years ago

I've come across this just now too. Conveniently after we put something into prod.... Bad form it's been open this long, but whatever, have got a solution that works for us.

I've just defined the current_or_guest_user method directly on my ApplicationController like so:

def current_or_guest_user
    if current_user
      session[:guest_user_id] = nil if session[:guest_user_id]
      current_user
    else
      guest_user
    end
  end

Due to FK contraints the guest user deletion was never working for us anyway, that's a task for another day.

mantenie commented 5 years ago

I also have this problem.

FocusedWanderer commented 5 years ago

In case it helps others, this code change fixed my issues (un-merged, pull request) : https://github.com/cbeer/devise-guests/pull/19

pacso commented 3 years ago

Fixed in #34