【发布时间】:2018-08-07 20:32:12
【问题描述】:
在我的 rails 项目中,我运行 rake routes 并得到以下输出:
Prefix Verb URI Pattern Controller#Action
obelisk_callflow_nodes GET /obelisk/callflows/:callflow_id/nodes(.:format) obelisk/nodes#index
POST /obelisk/callflows/:callflow_id/nodes(.:format) obelisk/nodes#create
new_obelisk_callflow_node GET /obelisk/callflows/:callflow_id/nodes/new(.:format) obelisk/nodes#new
edit_obelisk_callflow_node GET /obelisk/callflows/:callflow_id/nodes/:id/edit(.:format) obelisk/nodes#edit
obelisk_callflow_node GET /obelisk/callflows/:callflow_id/nodes/:id(.:format) obelisk/nodes#show
PATCH /obelisk/callflows/:callflow_id/nodes/:id(.:format) obelisk/nodes#update
PUT /obelisk/callflows/:callflow_id/nodes/:id(.:format) obelisk/nodes#update
DELETE /obelisk/callflows/:callflow_id/nodes/:id(.:format) obelisk/nodes#destroy
obelisk_callflows GET /obelisk/callflows(.:format) obelisk/callflows#index
POST /obelisk/callflows(.:format) obelisk/callflows#create
new_obelisk_callflow GET /obelisk/callflows/new(.:format) obelisk/callflows#new
edit_obelisk_callflow GET /obelisk/callflows/:id/edit(.:format) obelisk/callflows#edit
obelisk_callflow GET /obelisk/callflows/:id(.:format) obelisk/callflows#show
PATCH /obelisk/callflows/:id(.:format) obelisk/callflows#update
PUT /obelisk/callflows/:id(.:format) obelisk/callflows#update
DELETE /obelisk/callflows/:id(.:format) obelisk/callflows#destroy
我有一个 html.slim 文件用于显示所有调用流(即 obelisk/nodes#index)。在这个文件中,我想添加一个按钮来显示每个调用流的节点(即将该按钮连接到obelisk_callflow_nodes GET /obelisk/callflows/:callflow_id/nodes)
我试过= link_to 'Nodes', obelisk_callflow_nodes_path(callflow_id: c.id), method: :get, class: 'btn btn-primary' 其中c 是一个调用流对象。我已经检查了 c 是我想要的,因为我有 c.name 正确渲染。但是,我收到以下错误:
undefined methodobelisk_callflow_nodes_path' 用于#`
我已经检查过我的 Obelisk::NodesController 确实有一个索引方法
【问题讨论】:
-
试试这样
obelisk_callflow_nodes_path(c.id),你不需要设置参数的名称,只需按照它们在路由中配置的顺序传递它们 -
停止 rails 服务器,然后
spring stop并再次启动服务器。试试这个。 -
试过
obelisk_callflow_nodes_path(c.id)并得到错误 undefined method `obelisk_callflow_nodes_path' for #:0x00007efc4092ceb0> -
你确定 c.id 有一个有效的 id 吗?你能把错误的屏幕截图吗?
-
可以显示服务器日志吗?
标签: html ruby-on-rails ruby slim-lang