Why is there no double render when using before_action?

I am wondering why there is no double render when there is redirect_to or render in before_action . Consider this example:

 class SomeController < ApplicationController before_action :callback def new callback2 render 'new' end def callback render 'new' end def callback2 render 'new' end end 

I see that before_action will be useless if it cannot redirect, but how is it done? If I comment before_action , it will throw an exception. How is before_action implemented so as not to cause double rendering?

+8
ruby ruby-on-rails
source share
1 answer

See the Rails manual on controllers :

If the "before" filter displays or redirects, the action will not be performed. If after this filter additional filters are run, they will also be canceled.

+15
source share

All Articles