Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/62.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails Rails 4:使用partials进行路由_Ruby On Rails_Url_Routing - Fatal编程技术网

Ruby on rails Rails 4:使用partials进行路由

Ruby on rails Rails 4:使用partials进行路由,ruby-on-rails,url,routing,Ruby On Rails,Url,Routing,在Rails应用程序中导航时出现以下错误: 没有路线匹配 {:action=>"startnew", :controller=>"tickets", :ticket_id=>4} missing required keys: [:id] 问题是,我有一条路线: post 'tickets/:id/startnew' => 'tickets#startnew', as: :start_new 当我导航到URLhttp://localhost:3000/ticke

在Rails应用程序中导航时出现以下错误: 没有路线匹配

{:action=>"startnew", :controller=>"tickets", :ticket_id=>4} missing required keys: [:id]
问题是,我有一条路线:

  post   'tickets/:id/startnew' => 'tickets#startnew', as: :start_new
当我导航到URL
http://localhost:3000/tickets
但是当我加载URL
http://localhost:3000/tickets?id=4
,在我的例子中,这需要工作,因为我在tickets索引上呈现tickets#list和tickets#show两部分,上面的错误就发生在这里。 当我点击另一个页面上的链接时,将加载tickets#索引,而tickets#show仅在url中有参数时才会呈现(
http://localhost:3000/tickets?id=4

在show中,我有这个部分,它导致了问题:

<%= link_to 'Book time', start_new_path(ticket_id: @ticket.id), method: :post, class: "button info block-shadow-info text-shadow", remote: true %>

你能给我一个提示吗

没有路由匹配{:action=>“startnew”,:controller=>“tickets”, :ticket_id=>4}缺少必需的密钥:[:id]

你有

post   'tickets/:id/startnew' => 'tickets#startnew', as: :start_new
这意味着它需要
:id
作为密钥,但您正在发送
:ticket\u id
。将您的链接更改为下面的链接应该会起作用

<%= link_to 'Book time', start_new_path(id: @ticket.id), method: :post, class: "button info block-shadow-info text-shadow", remote: true %>

没有路由匹配{:action=>“startnew”,:controller=>“tickets”, :ticket_id=>4}缺少必需的密钥:[:id]

你有

post   'tickets/:id/startnew' => 'tickets#startnew', as: :start_new
这意味着它需要
:id
作为密钥,但您正在发送
:ticket\u id
。将您的链接更改为下面的链接应该会起作用

<%= link_to 'Book time', start_new_path(id: @ticket.id), method: :post, class: "button info block-shadow-info text-shadow", remote: true %>


在参数中更改
:ticket\u id
:id
,或将路线更改为
post'tickets/:ticket\u id/startnew'=>“tickets\35; startnew”,as::start\u new
是否可以运行
rake routes | grep start
并共享结果?在参数中更改
:ticket\u id
:id,或者将路线更改为“发布”tickets/:ticket_id/startnew'=>“tickets#startnew”,如::start_new您可以运行
rake routes | grep start
并共享结果吗?