I define each actions in my controller this way (in routes.rb):
resources :home do
collection do
get "home/index"
get "home/about_me"
get "home/contact"
end
end
If I would use a match for the action about_me, I have to use
resources :home do
collection do
get "home/index"
get "home/about_me"
get "home/contact"
end
end
match 'about-me' => 'home#about_me'
Exist any way, how to add match rule direct into a collection? I mean something like this:
resources :home do
collection do
get "home/index"
get "home/about_me", match => "about-me"
get "home/contact"
end
end
And I have one question yet – when I use in the routes.rb the second block of code, so when I set the URL address about-me, so the address works fine, but when I type there home/about_me, so I get the error
Unknown action: The action ‘show’ could not be found for HomeController.
What caused this error?
I think the problem here is that your routes have the
home/prefix when they are nested insideresources :home. Try this:Also, when you have trouble setting your routes, type
rake routesin your console. This will generate the routes of your app and the corresponding paths and controllers.EDIT: Here’s the answer to your other question.