更改路线后,Rails成员路径前缀不更新

时间:2019-05-29 21:21:10

标签: ruby-on-rails ruby

我正在对Rails应用程序进行一些重构,并将表拆分为两个。为此,我需要重命名原始模型,然后添加一个新模型并迁移数据。重命名表和模型后,我更改了资源的路由。它仅更新了某些路由的前缀。这里发生了什么?该资源以前称为“服务”。这是相关的路线:

class MySpinner(context: Context, attrSet: AttributeSet): Spinner(context, attrSet) {
    override fun onWindowFocusChanged(hasWindowFocus: Boolean) {
        Toast.makeText(context.applicationContext, "WindowFocusChanged! $hasWindowFocus", Toast.LENGTH_LONG).show()
        super.onWindowFocusChanged(hasWindowFocus)
    }
}

这是“耙路”的输出

resources :notices, only: %i[index edit update destroy] do
get 'close', on: :member
get 'cancel_or_close', on: :member
get 'new_lockout', on: :member
post 'create_lockout', on: :member
get 'new_five_days', on: :collection
post 'create_five_days', on: :collection
post 'batch_update', on: :collection
# This bit of nuttiness is to solve an issue regarding submitting the same form to multiple actions
post 'edit_multiple', on: :collection, constraints: CommitParamRouting.new('create_pdfs'), action: 'create_pdfs'
post 'edit_multiple', on: :collection, constraints: CommitParamRouting.new('create_envelopes'), action: 'create_envelopes'
post 'edit_multiple', on: :collection, constraints: CommitParamRouting.new('mark_canceled'), action: 'mark_canceled'
post 'edit_multiple', on: :collection, constraints: CommitParamRouting.new('mark_processing'), action: 'mark_processing'
post 'edit_multiple', on: :collection, constraints: CommitParamRouting.new('mark_filed'), action: 'mark_filed'
post 'edit_multiple', on: :collection, constraints: CommitParamRouting.new('mark_out_for_service'), action: 'mark_out_for_service'
post 'edit_multiple', on: :collection, constraints: CommitParamRouting.new('mark_service_complete'), action: 'mark_service_complete'
post 'edit_multiple', on: :collection, constraints: CommitParamRouting.new('mark_reconciled'), action: 'mark_reconciled'
post 'edit_multiple', on: :collection, constraints: CommitParamRouting.new('mark_closed'), action: 'mark_closed'
post 'edit_multiple', on: :collection, constraints: CommitParamRouting.new('mark_billed'), action: 'mark_billed'
post 'edit_multiple', on: :collection, constraints: CommitParamRouting.new('get_unbilled_csv'), action: 'get_unbilled_csv'
post 'edit_multiple', on: :collection, constraints: CommitParamRouting.new('export_serves_csv'), action: 'export_serves_csv'
post 'edit_multiple', on: :collection, constraints: CommitParamRouting.new('batch_edit'), action: 'batch_edit'
end

如您所见,某些路由已正确更新了其前缀,但其他路由仍在其前缀中保留服务(成员路由)。为什么会这样?

编辑: 这是一些模型代码:

close_serve GET    /notices/:id/close(.:format)                                                             notices#close
    cancel_or_close_serve GET    /notices/:id/cancel_or_close(.:format)                                                   notices#cancel_or_close
        new_lockout_serve GET    /notices/:id/new_lockout(.:format)                                                       notices#new_lockout
     create_lockout_serve POST   /notices/:id/create_lockout(.:format)                                                    notices#create_lockout
    new_five_days_notices GET    /notices/new_five_days(.:format)                                                         notices#new_five_days
 create_five_days_notices POST   /notices/create_five_days(.:format)                                                      notices#create_five_days
     batch_update_notices POST   /notices/batch_update(.:format)                                                          notices#batch_update
    edit_multiple_notices POST   /notices/edit_multiple(.:format)                                                         notices#create_pdfs
                          POST   /notices/edit_multiple(.:format)                                                         notices#create_envelopes
                          POST   /notices/edit_multiple(.:format)                                                         notices#mark_canceled
                          POST   /notices/edit_multiple(.:format)                                                         notices#mark_processing
                          POST   /notices/edit_multiple(.:format)                                                         notices#mark_filed
                          POST   /notices/edit_multiple(.:format)                                                         notices#mark_out_for_service
                          POST   /notices/edit_multiple(.:format)                                                         notices#mark_service_complete
                          POST   /notices/edit_multiple(.:format)                                                         notices#mark_reconciled
                          POST   /notices/edit_multiple(.:format)                                                         notices#mark_closed
                          POST   /notices/edit_multiple(.:format)                                                         notices#mark_billed
                          POST   /notices/edit_multiple(.:format)                                                         notices#get_unbilled_csv
                          POST   /notices/edit_multiple(.:format)                                                         notices#export_serves_csv
                          POST   /notices/edit_multiple(.:format)                                                         notices#batch_edit
                  notices GET    /notices(.:format)                                                                       notices#index
               edit_serve GET    /notices/:id/edit(.:format)                                                              notices#edit
                    serve PATCH  /notices/:id(.:format)                                                                   notices#update
                          PUT    /notices/:id(.:format)                                                                   notices#update
                          DELETE /notices/:id(.:format)  

0 个答案:

没有答案