Skip to content

Instantly share code, notes, and snippets.

@MaherSaif
Created January 13, 2011 21:24
Show Gist options
  • Save MaherSaif/778636 to your computer and use it in GitHub Desktop.
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
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