我认为我有以下代码(RoR 4):
tbody
- @order_submissions.each do |order_submission|
tr
td = order_submission.id
td.table-actions
span = link_to "Show", order_submissions_path(order_submission.id)
td = order_submission.id
成功显示为身份证号(533ab7337764690d6d000000)
但...
order_submissions_path(order_submission.id)
创建一个如下所示的 URL:
order_submissions.533ab7337764690d6d000000
我希望它是
order_submissions/533ab7337764690d6d000000
那个时期是从哪里来的?
这是我的路线:
get 'order_submissions/:id' => 'order_submissions#show'
当我运行 rake 路线时,我得到:
GET /order_submissions/:id(.:format) order_submissions#show
(.:format) 可能是什么搞砸了,但我不知道为什么。我只是希望它在那里放一个斜线。
如果我将代码更改为此它会修复它:
span = link_to "Show", order_submissions_path + '/' + order_submission.id
但这是一个非常非常愚蠢的解决方法。
编辑:这是我的路线:
get 'order_submissions' => 'order_submissions#index'
get 'order_submissions/new' => 'order_submissions#new'
post 'order_submissions' => 'order_submissions#create'
get 'order_submissions/:id' => 'order_submissions#show'
get 'order_submissions/:id/edit' => 'order_submissions#edit'
patch 'order_submissions/:id' => 'order_submissions#update'
get 'order_submissions/:id/delete' => 'order_submissions#delete'
delete 'order_submissions/:id' => 'order_submissions#destroy'