code_junkie

How do I check if a controller action is already redirecting

Nov 13th, 2011
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. class Payment < ApplicationController
  2. before_filter login_required
  3.  
  4. def new
  5. redirect_to some_other_path if @order.is_free?
  6. @payment = Payment.new
  7. end
  8. end
  9.  
  10. `render_with_no_layout': Can only render or redirect once per action
  11.  
  12. class PostsController < ApplicationController
  13. before_filter :perform_a_redirect, :except => [:wtf]
  14.  
  15. def index
  16. redirect_to 'http://google.com'
  17. end
  18.  
  19. def wtf
  20. render :text => 'wtf'
  21. end
  22.  
  23. private
  24.  
  25. def perform_a_redirect
  26. redirect_to :action => 'wtf'
  27. end
  28. end
Add Comment
Please, Sign In to add comment