Skip to content

Instantly share code, notes, and snippets.

@etaque
Created January 19, 2010 16:04
Show Gist options
  • Save etaque/281033 to your computer and use it in GitHub Desktop.
Save etaque/281033 to your computer and use it in GitHub Desktop.
def redirect_if_moved(record, param_key = :id)
canonical = record.to_param
if canonical != params[param_key]
redirect_to(:overwrite_params => { param_key => canonical }, :status => 301)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment