Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails for Zombies Level 5 Challenge 5

The problem statement is Create a named route. It should generate a path like '/zombies/:name' where :name is a parameter, and points to the index action in ZombiesController. Name the route 'graveyard'

the resources are Resources

zombies
id  name    graveyard
1   Ash     Glen Haven Memorial Cemetary
2   Bob     Chapel Hill Cemetary
3   Jim     My Fathers Basement

my solution is

TwitterForZombies::Application.routes.draw do
  match ':name' => 'Zombies#index', :as => 'graveyard'
end

i also tried

TwitterForZombies::Application.routes.draw do
      match ':name' => 'Zombie#index', :as => 'graveyard'
    end

the error that i get in both cases is

Sorry, Try Again
Did not route to ZombiesController index action with :name parameter

What am i doing wrong??

like image 246
nikhil Avatar asked May 17 '11 10:05

nikhil


1 Answers

Try this:

match '/zombies/:name',:to=> 'zombies#index', :as => 'graveyard'

RailsForZombies::Application.routes.draw do
    resources :zombie
    match '/zombies/:name',:to=> 'Zombies#index', :as => 'graveyard'
end
like image 108
Hitesh Avatar answered Oct 21 '22 04:10

Hitesh