ryanb/cancan — Issue #491: Cancan gem breaks devise gem "send password reset instructions"
Author: digitalfrost
Created: 2011-10-13 14:50:09+00:00
State: open

I'm cross posting this from https://github.com/plataformatec/devise/issues/1379
Adding the cancan gem to the Gemfile of the devise example app breaks the send password reset instructions" functionality.

I've forked the devise example app: https://github.com/digitalfrost/devise_cancan_debug
and added a functional test for "request password reset" to demonstrate the problem.

This is the error produced

```
NoMethodError: undefined method `new_session_path' for #
/home/gerald/.rvm/gems/ruby-1.9.2-p290/gems/devise-1.4.8/app/controllers/devise/passwords_controller.rb:48:in `after_sending_reset_password_instructions_path_for'
/home/gerald/.rvm/gems/ruby-1.9.2-p290/gems/devise-1.4.8/app/controllers/devise/passwords_controller.rb:17:in `create'
/home/gerald/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.0.10/lib/action_controller/metal/implicit_render.rb:4:in `send_action'
/home/gerald/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.0.10/lib/abstract_controller/base.rb:150:in `process_action'
/home/gerald/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.0.10/lib/action_controller/metal/rendering.rb:11:in `process_action'
/home/gerald/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.0.10/lib/abstract_controller/callbacks.rb:18:in `block in process_action'
/home/gerald/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.0.10/lib/active_support/callbacks.rb:446:in `_run__1739912974408911624__process_action__2985759677419550871__callbacks'
/home/gerald/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.0.10/lib/active_support/callbacks.rb:410:in `_run_process_action_callbacks'
/home/gerald/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.0.10/lib/active_support/callbacks.rb:94:in `run_callbacks'
/home/gerald/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.0.10/lib/abstract_controller/callbacks.rb:17:in `process_action'
/home/gerald/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.0.10/lib/action_controller/metal/rescue.rb:17:in `process_action'
/home/gerald/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.0.10/lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
/home/gerald/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.0.10/lib/active_support/notifications.rb:52:in `block in instrument'
/home/gerald/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.0.10/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
/home/gerald/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.0.10/lib/active_support/notifications.rb:52:in `instrument'
/home/gerald/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.0.10/lib/action_controller/metal/instrumentation.rb:29:in `process_action'
/home/gerald/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.0.10/lib/abstract_controller/base.rb:119:in `process'
/home/gerald/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.0.10/lib/abstract_controller/rendering.rb:41:in `process'
/home/gerald/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.0.10/lib/action_controller/metal/testing.rb:12:in `process_with_new_base_test'
/home/gerald/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.0.10/lib/action_controller/test_case.rb:412:in `process'
/home/gerald/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.0.10/lib/action_controller/test_case.rb:47:in `process'
/home/gerald/.rvm/gems/ruby-1.9.2-p290/gems/devise-1.4.8/lib/devise/test_helpers.rb:19:in `block in process'
/home/gerald/.rvm/gems/ruby-1.9.2-p290/gems/devise-1.4.8/lib/devise/test_helpers.rb:70:in `catch'
/home/gerald/.rvm/gems/ruby-1.9.2-p290/gems/devise-1.4.8/lib/devise/test_helpers.rb:70:in `_catch_warden'
/home/gerald/.rvm/gems/ruby-1.9.2-p290/gems/devise-1.4.8/lib/devise/test_helpers.rb:19:in `process'
/home/gerald/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.0.10/lib/action_controller/test_case.rb:355:in `post'
/home/gerald/devise_cancan_debug/test/functional/passwords_controller_test.rb:13:in `block in '
```

I've also written a monkey patch for anyone experiencing the same issue: https://github.com/digitalfrost/devise_cancan_debug/blob/72175aff9c851118eb2b6bd122b81e643e0a889a/config/application.rb
(lines 42-47)