Johnny Cash
Johnny Cash

Reputation: 5147

rails translated paths example

routes.rb

match "about/how_it_works" => "about#how_it_works", :as => "about_how_it_works", :via => :get
  match "about/we_are" => "about#we_are", :as => "about_we_are", :via => :get
  match "about/what_is" =>  "about#what_is", :as => "about_what_is", :via => :get

I read this rails guide and changed my code.

new routes.rb

scope(path_names: { about_we_are: 'translated-about-we-are', about_what_is: 'translated-about-what-is' }) do
  resources :about, path: 'translated-about'
end

But when I enter localhost:3000/about/translated-about-we-are, I encounter no route matches error.Do you know how can handle with this problem?

Upvotes: 0

Views: 279

Answers (1)

vee
vee

Reputation: 38645

Since you've specified path for resources about your path becomes translated-about/.... So you need to use:

http://localhost:3000/translated-about/translated-about-we-are

then you should not get the error.

You can check all the routes generated by issuing rake routes from within your application directory.

Upvotes: 0

Related Questions