【发布时间】:2011-12-09 07:03:41
【问题描述】:
我正在尝试使用 vote_fu gem,我遇到了其他人也有的问题,但我无法用其他人的解决方案解决这个问题..
我认为问题与 gem 没有直接关系.. 而是与某些错误的路线或缺少参数..
我有一个包含act_as_voteable 的消息模型。
对于用户模型,我添加了act_as_voter
在我添加的 Msg 控制器中
def votefor
@msg= Msg.find(params[:id])
current_user.vote_for(@msg)
redirect_to :back
end
在路线中:
resources :msgs do
member do
post :votefor
end
end
我在 Msg 的节目中添加了
<%= link_to "Vote Up", votefor_msg_path(@msg), :method => :post %>
但是当我点击创建的链接时,我得到了
Routing Error
No route matches [GET] "/msgs/1/votefor"
为什么它是“GET”而不是“POST”?我错过了什么?
【问题讨论】:
-
如果我使用 Button_to 一切正常,但使用 link_to 没有意义..