每次用户单击 link_to 时,方法都应更新属性。累积belongs_to :user 和:question
<%= link_to "+1", controller: "/accumulations", action: "vote_up",id: @question, user_id: current_user, method: "post" %>
def vote_up
@question = Question.find(params[:id])
@accumulation = Accumulation.where(user_id: current_user.id, question_id: @question.id )
累积的第三个属性是点:
@accumulation.point = Accumulation.increment_counter(:point, @accumulation)
@accumulation.save
redirect_to :back, notice: "+1"
end
它给了我这个信息:
#ActiveRecord::Relation:0xaa7fc10 的未定义方法 `point='
如何更新属性?