Created
November 7, 2014 07:26
-
-
Save vincentjiang/1711b2449b6b3996fc1b to your computer and use it in GitHub Desktop.
Rails代码片段
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 跳转至上一个URL,可带参数 | |
def redirect_to_back_or_default(default = root_url, *args) | |
if request.env['HTTP_REFERER'].present? && request.env['HTTP_REFERER'] != request.env['REQUEST_URI'] | |
redirect_to :back, *args | |
else | |
redirect_to default, *args | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment