I have a method in the parent class of a controller. It’s used as a before_filter (require_user) on most methods, but I need to call it like a helper_method. When I do so, the method doesn’t get called immediately, it is called asynchronously.
I don’t understand why this is happening.
Example code for the controllers and the error messages from the actual session are here https://gist.github.com/3187671
Any help is appreciated. Thanks!
Edit: I just found this post, which explains that it shouldn’t work; but doesn’t explain why it would call the helper asynchronously http://www.markhneedham.com/blog/2011/01/11/rails-using-helpers-inside-a-controller/
The
redirect_toorrendermethods do not halt the execution of the method. If you have to be sure that only one of them is called (otherwise Rails throws the DoubleRenderError, see guide 2.2.13). That’s the problem in your coderedirect_tois called byrequire_user, andrenderis called next.