我已将acts_as_votable配置为这样,以便在我的应用中生成内容的向上和向下滚动:
部分:
<div class="btn-group">
<%= link_to like_link_path(link), method: :put, class: "btn btn-success btn-sm" do %>
<span class="glyphicon glyphicon-chevron-up"></span>
Upvote
<%= link.get_upvotes.size %>
<% end %>
<%= link_to dislike_link_path(link), method: :put, class: "btn btn-warning btn-sm" do %>
<span class="glyphicon glyphicon-chevron-down">
Downvote
<%= link.get_downvotes.size %>
<% end %>
</div>
控制器:
def upvote
@link = Link.find(params[:id])
@link.upvote_by current_user
redirect_to :back
end
def downvote
@link = Link.find(params[:id])
@link.downvote_from current_user
redirect_to :back
end
路线:
resources :links do
member do
put "like", to: "links#upvote"
put "dislike", to: "links#downvote"
end
end
虽然我在我的路线和视图中非法地要求put请求,但我的日志显示我的浏览器正在尝试发出get请求:
Jan 12 16:43:24 quotesappp app/web.1: Started GET "/links/1/dislike" for 96.248.110.224 at 2016-01-13 00:43:23 +0000
当我在本地测试时,这不是问题,但在部署到Heroku时,它没有注册put请求。谁能看到我做错了什么?