I have the following rails route
model_name DELETE model_name/:id/comments/:id(.:format)
and I was wondering when I call params[:id]
in the destroy
method, what :id
does it take? The first or the second?
Your route should be
DELETE model_name/:model_id/comments/:id(.:format)
So params[:model_id] will take the first one and params[:id] will take the 2nd one(comment id)
for more details http://guides.rubyonrails.org/routing.html#nested-resources