This project is archived and is in readonly mode.
Specifying id in routes
Reported by iHiD | August 3rd, 2010 @ 12:43 AM
I am trying to specify the id parameter in the new routes interface.
An example use is if I have a table of pages in a database, and I want to give one a fixed url, pointing to the standard show method with the entry's id.
So, if I want a one-off route for the privacy policy page (e.g.
page 10), I would ideally want a route like this:
match "/privacy" => "pages#show#10", :as => "privacy_page"
The next best case would be:
match "/privacy" => "pages#show", :as => "privacy_page", :defaults => {:id => 10}
However, neither of these work and I am having to resort
to:
match "/privacy(/:id)" => "pages#show", :as => "privacy_page", :defaults => {:id => 10}
I've looked through the source and don't think I'm missing anything obvious.
Thanks,
iHiD
Comments and changes to this ticket
-
Rohit Arondekar October 7th, 2010 @ 06:35 AM
- Assigned user set to Andrew White
- Importance changed from to Low
-
Andrew White October 7th, 2010 @ 07:03 AM
- State changed from new to needs-more-info
Works as expected for me in 3.0.0:
# Explicit match '/privacy', :to => 'pages#show', :as => :privacy, :via => :get, :defaults => { :id => 10 } # Shorthand get '/privacy' => 'pages#show', :id => 10
iHiD, can you confirm that it's fixed for you?
-
Santiago Pastorino February 2nd, 2011 @ 04:58 PM
- State changed from needs-more-info to open
This issue has been automatically marked as stale because it has not been commented on for at least three months.
The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.
Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.
-
Santiago Pastorino February 2nd, 2011 @ 04:58 PM
- State changed from open to stale
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>