开发者

Ruby on rails redirect_to

what does it mean ? redirect_to开发者_高级运维 "" and return


According to the rails API docs: the return portion stops execution of anything else. In other words if you had the below the text would never print because of the return statement.

def go_home
    redirect_to(:action => "home") and return
    puts "This will never print"
  end

In the next example and return is called only if monkeys.nil? is true.

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

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜