问题陈述是
创建命名路由.它应该生成一个类似’/ zombies /:name’的路径,其中:name是一个参数,并指向ZombiesController中的索引操作.将路线命名为“墓地”
创建命名路由.它应该生成一个类似’/ zombies /:name’的路径,其中:name是一个参数,并指向ZombiesController中的索引操作.将路线命名为“墓地”
资源是
资源
zombies id name graveyard 1 Ash Glen Haven Memorial CeMetary 2 Bob Chapel Hill CeMetary 3 Jim My Fathers Basement
我的解决方案是
TwitterForZombies::Application.routes.draw do match ':name' => 'Zombies#index',:as => 'graveyard' end
我也试过了
TwitterForZombies::Application.routes.draw do match ':name' => 'Zombie#index',:as => 'graveyard' end
我在两种情况下得到的错误是
Sorry,Try Again Did not route to ZombiesController index action with :name parameter
我究竟做错了什么??
解决方法
试试这个:
match '/zombies/:name',:to=> 'zombies#index',:as => 'graveyard' RailsForZombies::Application.routes.draw do resources :zombie match '/zombies/:name',:to=> 'Zombies#index',:as => 'graveyard' end