Guest User

Untitled

a guest
Apr 23rd, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. To stop the before filter chain you use throw :halt with a few options:
  2.  
  3. # halts the filter chain and calls filters_halted which you can override
  4. # in your controller to specialize it.
  5.  
  6. throw :halt
  7.  
  8. # halts the filters and calls the method named after the symbol:
  9.  
  10. throw :halt, :other_action
  11.  
  12. # halts the filter chain and returns the result of the Proc being called
  13.  
  14. throw :halt, Proc.new{ |c| c.redirect "/foo" }
  15.  
  16. # halts the chain and returns whatever is in the string
  17.  
  18. throw :halt, "<h1>You don't have permissions dude!</h1>"
  19.  
  20. or even render templates:
  21.  
  22. throw :halt, render 'foo'
  23. throw :halt, partial 'foo'
Add Comment
Please, Sign In to add comment