Я занимался рефакторингом приложения Rails и разбивал таблицу на две части. Для этого необходимо переименовать исходную модель, а затем добавить новую и перенести данные. Я изменил маршрут для ресурса после переименования таблицы и модели. Обновлены только префиксы для некоторых маршрутов. Что тут происходит? Этот ресурс раньше назывался «подает». Вот соответствующие маршруты:
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
Вот вывод 'Rake Routes'
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)
Как видите, некоторые маршруты правильно обновили свои префиксы, но другие по-прежнему сохраняют в своем префиксе запросы на обслуживание (маршруты участников). Почему это происходит?
EDIT:
Вот некоторые из код модели:
class Notice < ApplicationRecord
belongs_to :client
belongs_to :affiant, optional: true
before_save :set_date_of_service, :set_default_billing_status, :set_default_affiant
class Affiant < ApplicationRecord
has_many :zip_codes
has_many :notices
class Client < ApplicationRecord
has_many :users
has_many :properties
has_many :notices
has_many :documents