Last active
November 20, 2015 08:41
-
-
Save sibsfinx/5441b2defad00c1d1e77 to your computer and use it in GitHub Desktop.
rails slug redirect
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
def show | |
@post = Post.friendly.find(params[:id]) | |
if request.path != post_path(@post) | |
expires_in 8.hours, :public => true | |
return redirect_to @post, :status => :moved_permanently | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment