【发布时间】:2014-01-27 21:43:24
【问题描述】:
为什么会出现此错误?我没有想法。
undefined method `update_attributes' for #
代码:
exists = Vote.where(comment_id: @comment.id).exists?
if exists
update_vote = Vote.where(comment_id: @comment.id)
update_vote.update_attributes(value: 5)
redirect_to :back
else
【问题讨论】:
-
此错误消息告诉您的是您的
update_vote.update_attributes未定义。在你的代码前面的某个地方,你应该定义update_attributes,否则你不能在这里使用它。
标签: ruby-on-rails mongodb ruby-on-rails-4 mongoid