0

From the example in rails guides, routes like:

resources :publishers do
  resources :magazines do
    resources :photos
  end
end

Will lead to, URLs like:

/publishers/1/magazines/2/photos/3

I want to have slugs for publishers for example - Oxford And avoid the first "/publishers" part Making the URLs to something like:

/oxford/1/magazines/2/photos/3

What is the cleanest and best way to achieve this in Rails 3?

whizcreed
  • 2,700
  • 3
  • 22
  • 35

1 Answers1

0
scope :path => ":publisher_slug", :as => "publisher" do
  resources :magazines do
    resources :photos
  end
end

publisher_magazine_photo_path("oxford",2,3)
Yuri Barbashov
  • 5,407
  • 1
  • 24
  • 20