problem with like link in nested resource
Hi Chris im doing the episode 'liking posts' i have difficult to do with deep nested resource,
my actual nested resources looks:
A. Routes:
resources :users do
resources :catalogs do
resources :pages do
resources :types do
resources :like, module: :types
end
end
end
end
B. link:
= link_to 'Like', [current_user, @catalog, @page, @type, @like], method: :post
C. Rake Routes:
user_catalog_page_type_like_index GET /users/:user_id/catalogs/:catalog_id/pages/:page_id/types/:type_id/like(.:format) types/like#index ____________________________ POST /users/:user_id/catalogs/:catalog_id/pages/:page_id/types/:type_id/like(.:format) types/like#create new_user_catalog_page_type_like GET /users/:user_id/catalogs/:catalog_id/pages/:page_id/types/:type_id/like/new(.:format) types/like#new
edit_user_catalog_page_type_like GET /users/:user_id/catalogs/:catalog_id/pages/:page_id/types/:type_id/like/:id/edit(.:format) types/like#edit
user_catalog_page_type_like GET /users/:user_id/catalogs/:catalog_id/pages/:page_id/types/:type_id/like/:id(.:format) types/like#show
PATCH /users/:user_id/catalogs/:catalog_id/pages/:page_id/types/:type_id/like/:id(.:format) types/like#update
PUT /users/:user_id/catalogs/:catalog_id/pages/:page_id/types/:type_id/like/:id(.:format) types/like#update
DELETE /users/:user_id/catalogs/:catalog_id/pages/:page_id/types/:type_id/like/:id(.:format) types/like#destroy
The link is not working, have any idea?
Thank you!
when i click i got this error message:
POST http://localhost:5000/users/modas-sol/catalogs/13/pages/10/types/24 404 (Not Found)
Oh of course. If you look at your routes, there is no POST
paths there. I think you can change the resources :like
to be singular instead like this: resource :like
and that will help.
In either case, your rake routes
should be creating a POST link to let you create a new like. It's odd that your current one doesn't have a POST route.