所以我有一个简单的模型歌曲,带有标题和喜欢作为属性。
我在歌曲索引页面上以表格形式显示它。我想在单击链接时增加喜欢的数量。
我目前认为:
<td> <%= link_to 'LIKE', :action => "update", :remote => true%> </td>
在我的 Songs_controller.rb 中,我有:
def update
@song = Song.find(params[:id])
@song.likes +=1
单击链接时出现此错误:
No route matches [GET] "/assets"
我知道这是基本的,有人可以帮助我了解这里发生了什么吗?
谢谢
更新!!!!!!!我把这个放在我的 application.rb 中
config.assets.enabled = false
但我仍然得到这个:
No route matches {:action=>"update", :remote=>true, :controller=>"songs"}
最佳答案
包裹您的 :action
参数以确保路由器实现 :remote
参数不是您路径的一部分:
<%= link_to 'LIKE', {:action => "update"}, :remote => true %>
关于ruby-on-rails - Link_to rails 导致路由错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9321250/