lassebunk/gretel — Issue #11: gretel is breaking devise 2.0
Author: ddidier
Created: 2012-02-26 17:07:53+00:00
State: open

Hi, from https://github.com/plataformatec/devise/issues/1678
I'll send you my test project

-----
First, I'm quite new with both ruby and rails, so maybe I'm missing something obvious, but...

I'm using devise-2.0.4 with cancan-1.6.7.
When I'm requesting a new password to be sent by email, I got

NoMethodError (undefined method `_with_routes' for nil:NilClass):
actionpack (3.2.1) lib/action_dispatch/routing/routes_proxy.rb:14:in `url_options'
actionpack (3.2.1) lib/action_dispatch/routing/routes_proxy.rb:28:in `new_user_session_path'
actionpack (3.2.1) lib/action_dispatch/routing/routes_proxy.rb:32:in `method_missing'
devise (2.0.4) lib/devise/controllers/url_helpers.rb:50:in `new_session_path'
devise (2.0.4) app/controllers/devise/passwords_controller.rb:44:in `after_sending_reset_password_instructions_path_for'
...

I traced this error :
at `url_helpers.rb:50` is sending a `new_user_session_path` message to `_devise_route_context`
then `url_options` is called but @scope is nil

As a workaround, in ApplicationController :

def new_session_path *args
case args[0]
when :user
new_user_session_path
else
raise "Unsupported scope: #{args[0]}"
end
end

thanks

-----

[...]
in gretel/helper_methods.rb on lines 3 to 5:

include ActionView::Helpers::UrlHelper
def controller # hack because ActionView::Helpers::UrlHelper needs a controller method
end

when commented out, that's working