My app was running on Rails 3.2.13 and everything was OK. Once i tried to update to Rails 4.2 i managed to fix all issues and now i can't reslov the problem with link_to. Here is one example:
<%= link_to 'Remove', {:controller=>'connect', :action=>'remove_from_cart', :id=> donation.id} %>
here is the error i am receiving wrong number of arguments (2 for 0..1):
From what i manage to find is that i must provide only one param into the link, and if i update the example from above to:
<%= link_to 'Remove', '/connect/remove_from_cart' + donation.id} %>
it will fix the problem, but i dont belive it is the right and very smart fix because i have lot of links across the application.
What might be the problem why link_to suddenly stop working afther the update?
Any help or suggestion will be appreciated! Thanks.
You should do this:
<%= link_to 'Remove', '/connect/remove_from_cart', donation_id: donation.id %>
You could clean it up a bit more by putting this in your routes file:
post '/connect/remove_from_cart/:donation_id', to: 'connect#remove_from_cart', as: :remove_from_cart
and using this code for your link
<%= link_to 'Remove', remove_from_cart_path(donation_id: donation.id), method: :post %>