ruby-on-railsauthenticationsorcery

Rails/Sorcery: undefined method `remember_me_token=' for #<User ...>


I've been following the Sorcery tutorial to build simple password authentication for a new (blank) Rails app. I've followed it very closely except for translating the erb to haml as I go along.

Everything has worked fine except that when testing the logout function it throws an error that seems to stump Google (see title).

The application trace shows only

app/controllers/user_sessions_controller.rb:16:in `destroy'

highlighting the logout line in user_sessions_controller.rb:

def destroy
  logout
  redirect_to(:users, notice: 'Logged out!')
end

I'll dump the framework trace below (it means very little to me) and am very happy to provide further information if you let me know what would be helpful. Generic advice on how to debug this kind of error would also be welcome.

activemodel (5.1.6) lib/active_model/attribute_methods.rb:432:in `method_missing'
sorcery (0.12.0) lib/sorcery/adapters/active_record_adapter.rb:6:in `block in update_attributes'
sorcery (0.12.0) lib/sorcery/adapters/active_record_adapter.rb:5:in `each'
sorcery (0.12.0) lib/sorcery/adapters/active_record_adapter.rb:5:in `update_attributes'
sorcery (0.12.0) lib/sorcery/model/submodules/remember_me.rb:67:in `force_forget_me!'
sorcery (0.12.0) lib/sorcery/model/submodules/remember_me.rb:61:in `forget_me!'
sorcery (0.12.0) lib/sorcery/controller/submodules/remember_me.rb:34:in `forget_me!'
sorcery (0.12.0) lib/sorcery/controller.rb:149:in `block in before_logout!'
sorcery (0.12.0) lib/sorcery/controller.rb:149:in `each'
sorcery (0.12.0) lib/sorcery/controller.rb:149:in `before_logout!'
sorcery (0.12.0) lib/sorcery/controller.rb:69:in `logout'
actionpack (5.1.6) lib/action_controller/metal/basic_implicit_render.rb:4:in `send_action'
actionpack (5.1.6) lib/abstract_controller/base.rb:186:in `process_action'
actionpack (5.1.6) lib/action_controller/metal/rendering.rb:30:in `process_action'
actionpack (5.1.6) lib/abstract_controller/callbacks.rb:20:in `block in process_action'
activesupport (5.1.6) lib/active_support/callbacks.rb:131:in `run_callbacks'
actionpack (5.1.6) lib/abstract_controller/callbacks.rb:19:in `process_action'
actionpack (5.1.6) lib/action_controller/metal/rescue.rb:20:in `process_action'
actionpack (5.1.6) lib/action_controller/metal/instrumentation.rb:32:in `block in process_action'
activesupport (5.1.6) lib/active_support/notifications.rb:166:in `block in instrument'
activesupport (5.1.6) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
activesupport (5.1.6) lib/active_support/notifications.rb:166:in `instrument'
actionpack (5.1.6) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
actionpack (5.1.6) lib/action_controller/metal/params_wrapper.rb:252:in `process_action'
activerecord (5.1.6) lib/active_record/railties/controller_runtime.rb:22:in `process_action'
actionpack (5.1.6) lib/abstract_controller/base.rb:124:in `process'
actionview (5.1.6) lib/action_view/rendering.rb:30:in `process'
actionpack (5.1.6) lib/action_controller/metal.rb:189:in `dispatch'
actionpack (5.1.6) lib/action_controller/metal.rb:253:in `dispatch'
actionpack (5.1.6) lib/action_dispatch/routing/route_set.rb:49:in `dispatch'
actionpack (5.1.6) lib/action_dispatch/routing/route_set.rb:31:in `serve'
actionpack (5.1.6) lib/action_dispatch/journey/router.rb:50:in `block in serve'
actionpack (5.1.6) lib/action_dispatch/journey/router.rb:33:in `each'
actionpack (5.1.6) lib/action_dispatch/journey/router.rb:33:in `serve'
actionpack (5.1.6) lib/action_dispatch/routing/route_set.rb:844:in `call'
rack (2.0.5) lib/rack/etag.rb:25:in `call'
rack (2.0.5) lib/rack/conditional_get.rb:38:in `call'
rack (2.0.5) lib/rack/head.rb:12:in `call'
rack (2.0.5) lib/rack/session/abstract/id.rb:232:in `context'
rack (2.0.5) lib/rack/session/abstract/id.rb:226:in `call'
actionpack (5.1.6) lib/action_dispatch/middleware/cookies.rb:613:in `call'
activerecord (5.1.6) lib/active_record/migration.rb:556:in `call'
actionpack (5.1.6) lib/action_dispatch/middleware/callbacks.rb:26:in `block in call'
activesupport (5.1.6) lib/active_support/callbacks.rb:97:in `run_callbacks'
actionpack (5.1.6) lib/action_dispatch/middleware/callbacks.rb:24:in `call'
actionpack (5.1.6) lib/action_dispatch/middleware/executor.rb:12:in `call'
actionpack (5.1.6) lib/action_dispatch/middleware/debug_exceptions.rb:59:in `call'
web-console (3.6.2) lib/web_console/middleware.rb:135:in `call_app'
web-console (3.6.2) lib/web_console/middleware.rb:22:in `block in call'
web-console (3.6.2) lib/web_console/middleware.rb:20:in `catch'
web-console (3.6.2) lib/web_console/middleware.rb:20:in `call'
actionpack (5.1.6) lib/action_dispatch/middleware/show_exceptions.rb:31:in `call'
railties (5.1.6) lib/rails/rack/logger.rb:36:in `call_app'
railties (5.1.6) lib/rails/rack/logger.rb:24:in `block in call'
activesupport (5.1.6) lib/active_support/tagged_logging.rb:69:in `block in tagged'
activesupport (5.1.6) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (5.1.6) lib/active_support/tagged_logging.rb:69:in `tagged'
railties (5.1.6) lib/rails/rack/logger.rb:24:in `call'
sprockets-rails (3.2.1) lib/sprockets/rails/quiet_assets.rb:13:in `call'
actionpack (5.1.6) lib/action_dispatch/middleware/remote_ip.rb:79:in `call'
actionpack (5.1.6) lib/action_dispatch/middleware/request_id.rb:25:in `call'
rack (2.0.5) lib/rack/method_override.rb:22:in `call'
rack (2.0.5) lib/rack/runtime.rb:22:in `call'
activesupport (5.1.6) lib/active_support/cache/strategy/local_cache_middleware.rb:27:in `call'
actionpack (5.1.6) lib/action_dispatch/middleware/executor.rb:12:in `call'
actionpack (5.1.6) lib/action_dispatch/middleware/static.rb:125:in `call'
rack (2.0.5) lib/rack/sendfile.rb:111:in `call'
railties (5.1.6) lib/rails/engine.rb:522:in `call'
puma (3.11.4) lib/puma/configuration.rb:225:in `call'
puma (3.11.4) lib/puma/server.rb:632:in `handle_request'
puma (3.11.4) lib/puma/server.rb:446:in `process_client'
puma (3.11.4) lib/puma/server.rb:306:in `block in run'
puma (3.11.4) lib/puma/thread_pool.rb:120:in `block in spawn_thread'

Solution

  • Restarting the Rails server resolved the problem.