As per your defined routes, the DELETE
route is NOT a named route, so when you say slide_path(slide.album.id, slide.id)
in your link, rails routes would automatically try to match it with the listed routes prefixed with slide
and with DELETE
request.
To route the Delete Slide link properly to the DELETE route, you would need to update the routes as below:
resources :albums, except: :show do
resources :slides, shallow: true, except: [:destroy, :patch, :put]
match 'slides/:ids', to: 'slides#destroy', via: :delete, as: :slide ## Note as option
match 'slides/:ids/dest_album/:dest_album_id', to: 'slides#move', via: :patch
match 'slides/:ids/dest_album/:dest_album_id', to: 'slides#move', via: :put
end
This will create the DELETE
named route as below:
album_slide DELETE /albums/:album_id/slides/:ids(.:format) slides#destroy
Now, update the Delete Slide link to map to this route:
<%= link_to t('.destroy', :default => t("helpers.links.destroy")),
album_slide_path(slide.album.id, slide.id),
:method => :delete,
:class => 'btn btn-mini btn-danger',
:remote => true %>
UPDATE
Your route was NOT a named route. As per your currently defined routes slide_path
is only available for the following routes:
slide GET /slides/:id(.:format) slides#show
PATCH /slides/:id(.:format) slides#update
PUT /slides/:id(.:format)
which were created with resources :slides, shallow: true, except: [:destroy, :patch, :put]
So, when you called slide_path(slide.album.id, slide.id)
with two arguments, rails router tried to convert it into a path
/slides/:id(.:format)
so you received a request with path
slides/1.1
^ ^
a b
where
a
=> refers to :id
dynamic segment of the slide_path route and value of slide.album.id
was set to it
b
=> refers to (.:format)
part of the slide_path route and value of slide.id
was set to it. Format refers to the extension (.html, .json, etc) so you received .1
in the path as slide.id
was treated as format