Created
January 13, 2011 21:24
-
-
Save MaherSaif/778636 to your computer and use it in GitHub Desktop.
implement Quora/Facebook URLs like #ref http://www.quora.com/How-does-Quora-rewrite-their-urls
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
match '/:id', :to => proc { |env| | |
id = env["action_dispatch.request.path_parameters"][:id] | |
model = Slug.find_by_slug(id).model | |
controller = [model.pluralize.camelize,"Controller"].join.constantize | |
controller.action("show").call(env) | |
}, :as => :slugable |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment