Created
August 16, 2014 04:24
-
-
Save rgruesbeck/bc3d74ffc976d6151e9f to your computer and use it in GitHub Desktop.
This file contains 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
class PostsController < ApplicationController | |
+ require 'digest/md5' | |
def index | |
@posts = Post.published_posts | |
end | |
def show | |
- post = Post.friendly.find(params[:id]) | |
+ #hash for all the wierd reroute requests | |
+ reroutes = { | |
+ "209eb4f69c420d042f3ad47cb5d58f79" => "Napa County Alliance for Arts Education Launches 2014 Survey", | |
+ "4825dac1ac9c01a4460b76f37fa62f50" => "goodpost" | |
+ } | |
+ | |
+ #reassign the post_id to its pair if the reroute exists | |
+ routekey = Digest::MD5.hexdigest(params[:id]) | |
+ if reroutes.has_key?(routekey) | |
+ post_id = reroutes[routekey] | |
+ else | |
+ post_id = params[:id] | |
+ end | |
+ | |
+ post = Post.friendly.find(post_id) | |
@post = post if post.published | |
render :layout => 'application' | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment