У меня есть родительская модель User, и это дочерняя модель. Комментарий.Я хочу обновить атрибут profile_rating пользователя при создании комментария.Я пытаюсь использовать обратный вызов, и я добавил метод в классе комментариев.Я продолжаю получать сообщение об ошибке "profile_rating is undefined" Что я делаю не так?
class User < ApplicationRecord
has_many :comments,
dependent: :destroy
end
class Comment < ApplicationRecord
belongs_to :user
#update profile rating
after_save :update_profile_rating
def update_profile_rating
@new_profile_rating = user.profile_rating + 1
User.update(user.profile_rating: @new_profile_rating)
end
end