Having 2 models customer and comm_log. Their association is as below:
resources :customers do
comm_logs
end
The rspec code for destroy in comm_logs controller passed without any error. The lambda block verified that the comm log count was reduced by 1 after a successful delete. Everything in controller seems right.
The output of rake routes is:
new_customer_comm_log GET /customers/:customer_id/comm_logs/new(.:format) {:action=>"new", :controller=>"comm_logs"}
edit_customer_comm_log GET /customers/:customer_id/comm_logs/:id/edit(.:format) {:action=>"edit", :controller=>"comm_logs"}
customer_comm_log GET /customers/:customer_id/comm_logs/:id(.:format) {:action=>"show", :controller=>"comm_logs"}
PUT /customers/:customer_id/comm_logs/:id(.:format) {:action=>"update", :controller=>"comm_logs"}
DELETE /customers/:customer_id/comm_logs/:id(.:format) {:action=>"destroy", :controller=>"comm_logs"}
In reality, the record was not deleted after clicking the delete button and the page was not redirected to previous page as it is in the controller (the show page just remains and did not redirect to anywhere after deleting). It seems that the delete action was routed to the right path. The problem is most likely with the link_to below in views:
<%= link_to 'delete', customer_comm_log_path(@customer, @comm_log), :method => :delete, :confirm => "are you sure?", :remote => true %>
Is there anything wrong in link_to above? thanks.