This project is archived and is in readonly mode.
Rails 3 RC Routing: resource member routes lack defaults
Reported by Star Trader | August 24th, 2010 @ 01:47 AM | in 3.0.2
When adding additional actions to a resource as shown in 2.9 of
the routing guide (http://edgeguides.rubyonrails.org/routing.html),
the action and route naming is not done by default. For example,
placing the example code in a fresh app and running rake
routes
raises an error "missing :action" This can be fixed
by changing the line to get 'preview', :action=>'preview',
:as=>:preview.
Expected behavior:
1) The example code should parse
2) the action and route name should be inferred
Comments and changes to this ticket
-
Santiago Pastorino August 24th, 2010 @ 05:23 AM
- Importance changed from to Low
I can't reproduce this, can you provide more info, try doing a test case or upload an application?.
Thanks. -
Andrew White August 24th, 2010 @ 07:03 AM
- Milestone cleared.
- State changed from new to open
- Assigned user set to Andrew White
I think the problem is the guide shows the example using a string, whereas it should really be a symbol. I can't reproduce the missing action error but it is correct that the route isn't named.
The action is added here, however I leaning towards thinking that it should removed and require the action to be specified. The problem with adding the action and name by default when specifying a custom action as a string is that you can add extra parameters in the path so you should really be adding all the options. e.g:
resources :photos do get 'preview/:size', :on => :member end
It wouldn't add too much overhead to add a regexp check on the name to see if it's compatible with adding it by default I guess, but the guide definitely needs updating.
-
Andrew White August 24th, 2010 @ 07:43 AM
Okay, here's a patch to add a default name and action if the string is just alphanumeric.
-
Santiago Pastorino August 24th, 2010 @ 12:20 PM
- Assigned user changed from Andrew White to José Valim
I should be sleepy when i watched to this but i agree with Andrew, also +1 for the patch.
Just wait for José resolution :). -
Repository August 24th, 2010 @ 02:25 PM
- State changed from open to resolved
(from [7a7012c7177fd9811305c03b1db0ec0d5008f19e]) Fix a bug where symbols and strings were not behaving the same in the router. [#5431 state:resolved] http://github.com/rails/rails/commit/7a7012c7177fd9811305c03b1db0ec...
-
Repository August 24th, 2010 @ 02:25 PM
(from [8feb2856ea1e813bdefe64e9820cd1005aa5ad92]) When custom resource actions are specified using strings add the default name and action if the string is a valid ruby method name.
[#5431 state:resolved]
Signed-off-by: José Valim jose.valim@gmail.com
http://github.com/rails/rails/commit/8feb2856ea1e813bdefe64e9820cd1... -
Repository August 24th, 2010 @ 02:26 PM
(from [b4f304b7b68e0b4fd780cc6d0944edefc362669d]) Fix a bug where symbols and strings were not behaving the same in the router. [#5431 state:resolved] http://github.com/rails/rails/commit/b4f304b7b68e0b4fd780cc6d0944ed...
-
Repository August 24th, 2010 @ 02:26 PM
(from [2fb0cbec024c5b51451deab7e390e2d4f712cf8f]) When custom resource actions are specified using strings add the default name and action if the string is a valid ruby method name.
[#5431 state:resolved]
Signed-off-by: José Valim jose.valim@gmail.com
http://github.com/rails/rails/commit/2fb0cbec024c5b51451deab7e390e2...
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="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>
People watching this ticket
Attachments
Tags
Referenced by
- 5431 Rails 3 RC Routing: resource member routes lack defaults (from [7a7012c7177fd9811305c03b1db0ec0d5008f19e]) Fix a b...
- 5431 Rails 3 RC Routing: resource member routes lack defaults [#5431 state:resolved]
- 5431 Rails 3 RC Routing: resource member routes lack defaults (from [b4f304b7b68e0b4fd780cc6d0944edefc362669d]) Fix a b...
- 5431 Rails 3 RC Routing: resource member routes lack defaults [#5431 state:resolved]