Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

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

#13

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.

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

State: invalid
Milestone: none
Assigned to: josh josh
Importance: none

Activity

  1. jack dempsey (jackdempsey)
  2. Sam Granieri
    Sam Granieri

    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

    April 16th, 2008 @ 11:35 PM

  3. josh
    josh
    • 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.

    April 17th, 2008 @ 01:09 AM

  4. josh
    josh
    • Title changed from [PATCH] Allow SEO friendly resources (ex. /my-resources) to Allow SEO friendly resources (ex. /my-resources)

    April 17th, 2008 @ 01:12 AM

  5. Doug Ramsay
    Doug Ramsay

    Joshua

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

    :my_resources

    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).

    April 17th, 2008 @ 01:36 AM

  6. josh
    josh
    • 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.

    April 19th, 2008 @ 10:37 PM

  7. jack dempsey (jackdempsey)
    jack dempsey (jackdempsey)

    Joshua,

    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.

    April 19th, 2008 @ 10:55 PM

  8. Doug Ramsay
    Doug Ramsay

    Joshua,

    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).

    April 19th, 2008 @ 11:29 PM

  9. blj