Created
September 20, 2010 11:23
-
-
Save accuser/587758 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
# 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