Link_to rails causing routing error

so I have simple models with a title and like attributes.

I show it as a table on the song index page. I want to increase the number I liked when I click a link.

I have this, in my opinion, now:

<td> <%= link_to 'LIKE', :action => "update", :remote => true%> </td> 

in my song_controller.rb I have:

 def update @song = Song.find(params[:id]) @song.likes +=1 

I get this error when clicking a link:

 No route matches [GET] "/assets" 

I know this is simple, someone, please help me understand what is happening here?

thanks

UPDATE !!!!!!! I put this in my application .rb config.assets.enabled = false

but I still get the following:

 No route matches {:action=>"update", :remote=>true, :controller=>"songs"} 
+4
source share
2 answers

Wrap your argument :action to ensure that the router implements the argument :remote not part of your path:

 <%= link_to 'LIKE', {:action => "update"}, :remote => true %> 
+4
source

This is a good answer that I found when I had problems with the same thing. Rails 3 how to add a custom method to a controller

This post also has a good link to railscast, which also explains part of the problem.

0
source

Source: https://habr.com/ru/post/1396951/


All Articles