Skip to content

Instantly share code, notes, and snippets.

@ciscou
Created August 27, 2014 08:44
Show Gist options
  • Save ciscou/678f3283a97f1de744fc to your computer and use it in GitHub Desktop.
Save ciscou/678f3283a97f1de744fc to your computer and use it in GitHub Desktop.
class PocController
before_filter :redirect_to_root_url, only: :show4
def show1
redirect_to_root_url
render # => Double render error!!!
end
def show2
redirect_to_root_url
# => No explicit render, so rails is smart enough to know that a redirect_to has been called and no template is rendered
end
def show3
redirect_to_root_url_returning_true and return
render # => Never called because of "and return" above
end
def show4
render # => show method is never called as the filter chain is halted (see before_filter above)
end
def show5
# => show5 template is rendered (implicit)
end
def show6
render # => show6 template is rendered (explicit)
end
def show7
render "omg" # => omg template is rendered (explicit)
end
private
def redirect_to_root_url
redirect_to root_url
end
def redirect_to_root_url_returning_true
redirect_to root_url
true
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment