Skip to content

Instantly share code, notes, and snippets.

@accuser
Created September 20, 2010 11:23
Show Gist options
  • Save accuser/587758 to your computer and use it in GitHub Desktop.
Save accuser/587758 to your computer and use it in GitHub Desktop.
# config/initializers/routes_with_slugs.rb
require 'action_dispatch'
module ActionDispatch
module Routing
class Mapper
module Resources
RESOURCE_OPTIONS << :slug
class Resource
def member_scope_with_slug
if @options[:slug]
"#{path}/:id(/:slug)"
else
member_scope_without_slug
end
end
alias_method_chain :member_scope, :slug
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment