'undefined method `update_attributes' while having no update_attributes in Rails 7 with Votable Gem
I ran into the undefined method `update_attributes' while having no update_attributes
it showed to me that the following code has issue (Acts As Votable gem)
@message.liked_by current_user
This is my controller
def upvote
@message = Message.find(params[:id])
flash[:notice] = 'Upvoted!'
if current_user.voted_up_on? @message
@message.downvote_from current_user
elsif current_user.voted_down_on? @message
@message.liked_by current_user
else
@message.liked_by current_user
end
end
It happens after the migration of the following code
class AddCachedVotesToPosts < ActiveRecord::Migration
def change
change_table :posts do |t|
t.integer :cached_votes_total, default: 0
t.integer :cached_votes_score, default: 0
t.integer :cached_votes_up, default: 0
t.integer :cached_votes_down, default: 0
t.integer :cached_weighted_score, default: 0
t.integer :cached_weighted_total, default: 0
t.float :cached_weighted_average, default: 0.0
end
end
end
Also, did the global search and find no update_attributes.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
