New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"request" is nil within DeviseController when subclassing a Devise controller and using scoped views #1859
Comments
Thanks for the detailed report, we will take a look. |
I should also mention that the |
I have some additional information on this bug. I tracked it down to the order of instance variables assigned in this file, particular the order of @controller.formats= and @controller.request=
This process() method has an assignment: @controller.formats = nil which ends up calling into ActionView, and eventually Devise to figure out whether to use scoped views or not (and explodes because request is undefined). Request is undefined because the line @controller.request = @request happens after the @controller.formats= call. Once I moved @controller.request = @request before the formats assignment, Devise no longer explodes. In summary, it looks like in the context of functional controller tests, Devise relies on request object being setup to determine supported formats of the controller, but it can not rely on the request object yet because it wasn't assigned. I am not clear whether it's a Devise issue, or ActionSupport issue, but it is very surprising that it hasn't gotten caught before. Basically any controller tests with scoped views with Devise would be broken. |
Thanks for the detailed report. I have added a fix for Devise master, can you please check it works for you? Thanks! |
Seems to be fixed! We are now getting a proper result from posting to an action. Thank you so much! |
We have a Github repo reproducing this issue:
https://github.com/atasay/devise-issue
If you run the tests by running the default rake task, you will see the error we're getting.
This is the exception:
At the top of the stack trace, it says the error is coming from devise_controller.rb:38, which looks like this:
So
request
is actually nil here. And this is within DeviseController while callingpost :create
.This is the full test:
This is on Devise 2.1.0 and Rails 3.2.3 but we first noticed the issue with Devise 2.0.4.
Thanks in advance for any suggestions.
The text was updated successfully, but these errors were encountered: