This project is archived and is in readonly mode.

#13 ✓invalid
Doug Ramsay

Allow SEO friendly resources (ex. /my-resources)

Reported by Doug Ramsay | April 16th, 2008 @ 09:29 PM

Updated actionpack/lib/action_controller/resources.rb to generate

standard controller name from resource containing hyphen

(ex. :'my-resources').

Updated actionpack/lib/action_controller/routing/route_set.rb to

translate hyphens to underscores in resource names.

Comments and changes to this ticket

  • jack dempsey (jackdempsey)
  • Sam Granieri

    Sam Granieri April 16th, 2008 @ 11:35 PM

    As soon as the patch is modified with tests that verify that it works and it doesnt break anything else i'll give it a +1

  • josh

    josh April 17th, 2008 @ 01:09 AM

    • State changed from “new” to “open”
    • Assigned user set to “josh”

    So this will change any resource with an _ to a -? Example, /open_tickets becomes /open-tickets. If so this is going break everyones urls.

  • josh

    josh April 17th, 2008 @ 01:12 AM

    • Title changed from “[PATCH] Allow SEO friendly resources (ex. /my-resources)” to “Allow SEO friendly resources (ex. /my-resources)”
  • Doug Ramsay

    Doug Ramsay April 17th, 2008 @ 01:36 AM


    I think you're reading the patch wrong. If somebody puts in a resource such as:


    the resource will be unaffected. The change will only affect resources that have a dash, such as :'my-resources'.

    Granted, to Sam's point, I need to add tests for this. The problem I'm having is that the tests and custom assertions in actionpack/test/controller/resources_test.rb make a lot of assumptions about how resources will be passed in. Also, none of the existing tests are run with a resource containing an underscore, such as :my_resources with a controller MyResourcesController (file: my_resources_controller.rb).

  • josh

    josh April 19th, 2008 @ 10:37 PM

    • State changed from “open” to “invalid”

    I'm really opposed to these kinds of changes. However, there should be a workaround if you really need to do it.

    map.resources :valid_orders, :as => 'valid-orders'

    Let me know if that doesn't work for you.

  • jack dempsey (jackdempsey)

    jack dempsey (jackdempsey) April 19th, 2008 @ 10:55 PM


    What exactly does "these kinds of changes" mean? If you have a resource named "foo-bar" wouldn't you expect the end result url to have a dash and not an underscore?

    I think :as => 'foo-bar' would work as well, just don't see why...can you think of a situation where the programmer would want :'foo-bar' to be 'foo_bar' in the url? (if they did they'd just use :foo_bar right?)

    So, just curious.

  • Doug Ramsay

    Doug Ramsay April 19th, 2008 @ 11:29 PM


    I see what you're saying, and your solution does work. My thought was that this would offer a good alternative.

    For now, I plan to submit another patch for resources_test.rb which includes tests for multi-word resources, and for the :as option with multi-word resources (neither of which are currently covered).

  • blj

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href=""></a>


Referenced by