28th Jul, 2009

Rails - Calling multiple redirects or renders fix

Use the “return” statement to fix this issue.

(E.g)

def do_something
redirect_to(:action => “elsewhere”) and return if monkeys.nil?
render :action => “overthere” # won’t be called if monkeys is nil
end

(copied from http://api.rubyonrails.org/classes/ActionController/Base.html)

Leave a response

Your response:

Categories and Tags

Advertising