Rails for Zombie Level 5 Challenge 2 - Custom Routes
The objective is to create a custom route so that /undead will go to the undead action on the ZombiesController.
My code:
TwitterForZombies::Application.routes.draw do
resources :zombies
match 'show_zombie' => "undead#show"
end
And the error..."Did not add the correct route, could not get to Zombi开发者_高级运维esController#undead."
I'm not sure where i went wrong....
Your route notation should look like this:
match 'path' => 'controller#action'
So, the path is undead, the controller is zombies, and the action is undead:
match 'undead' => 'zombies#undead'
/undead goes to undead action
match 'undead' => 'zombies#undead'
You could replace match
by one of get, post, put, or delete
.
I think the question is changed now, solution is :
RailsForZombies::Application.routes.draw do
match 'undead' => 'Zombies#undead'
end
Read the objetive again :)
You want to get to ZombiesController#undead but you set it to go to ZombiesController#show
精彩评论