gpt4 book ai didi

ruby-on-rails-3 - 僵尸路轨5级挑战5

转载 作者:行者123 更新时间:2023-12-04 13:12:15 25 4
gpt4 key购买 nike

问题陈述是
创建一个命名的路由。它应该生成一个类似于'/zombies/:name'的路径,其中:name是一个参数,并指向ZombiesController中的index操作。将路线命名为“graveyard”

资源是
资源

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

关于ruby-on-rails-3 - 僵尸路轨5级挑战5,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6029787/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com