Skip to content

Instantly share code, notes, and snippets.

@etaque
Created January 18, 2010 00:37
Show Gist options
  • Save etaque/279697 to your computer and use it in GitHub Desktop.
Save etaque/279697 to your computer and use it in GitHub Desktop.
class ApplicationController < ActionController::Base
protected
def redirect_if_moved(record, param_key = :id)
redirect_to record, :status => 301 if record.to_param != params[param_key]
end
end
class PostsController < ApplicationController
def show
@post = Post.find(params[:id])
redirect_if_moved @post
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment