Прежде всего, я бы изменил ваш routes.rb
на что-то более похожее на:
resources :items, except: [:edit] do
member do
get :listing
get :pricing
get :description
get :photo_upload
get :location
get :preload
get :preview
post :archive
end
resources :photos, only: [:create, :destroy]
resources :reservations, only: [:create]
resources :calendars
end
Это даст вам (помимо прочего):
listing_item GET /items/:id/listing(.:format) items#listing
pricing_item GET /items/:id/pricing(.:format) items#pricing
description_item GET /items/:id/description(.:format) items#description
photo_upload_item GET /items/:id/photo_upload(.:format) items#photo_upload
location_item GET /items/:id/location(.:format) items#location
preload_item GET /items/:id/preload(.:format) items#preload
preview_item GET /items/:id/preview(.:format) items#preview
archive_item POST /items/:id/archive(.:format) items#archive
item_photos POST /items/:item_id/photos(.:format) photos#create
item_photo DELETE /items/:item_id/photos/:id(.:format) photos#destroy
item_reservations POST /items/:item_id/reservations(.:format) reservations#create
item_calendars GET /items/:item_id/calendars(.:format) calendars#index
POST /items/:item_id/calendars(.:format) calendars#create
new_item_calendar GET /items/:item_id/calendars/new(.:format) calendars#new
edit_item_calendar GET /items/:item_id/calendars/:id/edit(.:format) calendars#edit
item_calendar GET /items/:item_id/calendars/:id(.:format) calendars#show
PATCH /items/:item_id/calendars/:id(.:format) calendars#update
PUT /items/:item_id/calendars/:id(.:format) calendars#update
DELETE /items/:item_id/calendars/:id(.:format) calendars#destroy
items GET /items(.:format) items#index
POST /items(.:format) items#create
new_item GET /items/new(.:format) items#new
item GET /items/:id(.:format) items#show
PATCH /items/:id(.:format) items#update
PUT /items/:id(.:format) items#update
DELETE /items/:id(.:format) items#destroy
Затем измените:
<%= link_to "Archive", listing_item_path(item), method: :archive, class: 'btn-delete' , :data => {:confirm => 'Are you sure?'}%>
Кому:
<%= link_to "Archive", archive_item_path(item), method: :post, class: 'btn-delete' , :data => {:confirm => 'Are you sure?'}%>
В документах (в разделе «Параметры») вы заметите, что method
является символом HTTPи может быть :post
, :delete
, :patch
или :put
.Но НЕ :archive
.Это не HTTP-глагол.