Ruby on rails Rails 4:使用partials进行路由
在Rails应用程序中导航时出现以下错误: 没有路线匹配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
{:action=>"startnew", :controller=>"tickets", :ticket_id=>4} missing required keys: [:id]
问题是,我有一条路线:
post 'tickets/:id/startnew' => 'tickets#startnew', as: :start_new
当我导航到URLhttp://localhost:3000/tickets
但是当我加载URLhttp://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
并共享结果吗?