Notifications_count 问题与注意到的 gem

问题描述 投票:0回答:1

“我目前正在使用注意到的 gem 进行通知,并且遇到以下问题:

undefined method `notifications_count=' for #<AppointmentNotifier id: nil, type: "AppointmentNotifier", record_type: "Appointment", record_id: 15, params: {
=>"new Message"}, created_at: nil, updated_at: nil>. 

我在任何文件中都找不到错误,并且我没有调用该方法。错误只是突然发生。”

我在所有文件中搜索了任何可能干扰的方法,但我找不到任何东西。我还使用控制台查找错误

ruby-on-rails ruby rubygems
1个回答
0
投票

当你看到它返回时

undefined method 'xxxxxx'

在 ActiveRecord 对象上。

  1. 首先,您要确保这不是拼写错误。
  2. 如果不是拼写错误并且您没有定义此方法,它可能是一个列的名称,因为 ActiveRecord 使用元编程来“生成”列的所有方法
  3. notifications_count
    看起来像属于gem的列
    noticed
    所以我认为它与数据迁移有关

结论:

noticed
向表中添加了一些额外的列,您需要运行rails db:migrate首先添加这些新列。

© www.soinside.com 2019 - 2024. All rights reserved.