This project is archived and is in readonly mode.
Allow SEO friendly resources (ex. /my-resources)
-
jack dempsey (jackdempsey)
Looks good! +1
-
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
-
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.
-
josh
- Title changed from [PATCH] Allow SEO friendly resources (ex. /my-resources) to Allow SEO friendly resources (ex. /my-resources)
-
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).
-
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.
-
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.
-
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).
-
blj
use :as
