On 22 Mar., 11:16, "Paul A." <rails-mailing-l...@andreas-s.net> wrote:
> Hi, everybody
>
> Is there a way to simplify address path from:
>  http://0.0.0.0:3000/books/3/pages/1
> to this format:
>  http://0.0.0.0:3000/3/1
>
> My current routes.rb looks like:
>
> ActionController::Routing::Routes.draw do |map|
>   map.resources :books do |book|
>     book.resources :pages
>   end
> end
>
> Many thanks for your help,

map.short_book_page ":book_id/:id", :book_page

It's a named route, so you can call it like this: link_to "Page 2,
book 1", short_book_page_path(1, 2)

It's untested but it should work. Take a look at the documentation for
ActionController::Routing at 
http://api.rubyonrails.org/classes/ActionController/Routing.html

--
Best regards,
David Knorr
http://twitter.com/rubyguy
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to