html slim link_to未定义方法错误

时间:2018-08-07 20:32:12

标签: html ruby-on-rails ruby slim-lang

在我的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文件,用于显示所有呼叫流程(即方尖碑/ 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 method obelisk_callflow_nodes_path'for#<#:0x00007fb3d5abebc8>`

我检查了我的Obelisk :: NodesController是否具有索引方法

1 个答案:

答案 0 :(得分:0)

我更改了路由,以便不再使用namespace obelisk,因此路由不会以/ obelisk /开头。这样可以解决问题。我知道这可能不是最好的解决方案,但在这种情况下,它已达到我的项目目的。