我已经尝试解决这个问题大约两天了,但我对可能是什么问题已经没有想法了。我已经将我的应用程序推送到 Heroku,没有问题,但是当我尝试登录日志时会输出这个。 Heroku 日志
NameError(未初始化的常量 User::Story):
[ActiveJob] 将 ElasticsearchIndexJob(作业 ID:######)排队到 sidekiq(elasticsearch),参数:“index”,“User”,1
然后它指向我的方法位置
app/models/concerns/searchable_user.rb:43:in 'index_document'
def index_document
ElasticsearchIndexJob.perform_later('index', 'User', self.id)
self.stories.find_each do |storie|
ElasticsearchIndexJob.perform_later('index', 'Storie', storie.id) if storie.published?
end
end
从我使用Storie的项目开始,我不知道它认为Story来自哪里。
用户.rb
class User < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable,
:omniauthable, :omniauth_providers => [:facebook, :twitter, :google_oauth2]
validates :username, presence: true
validate :avatar_image_size
has_many :stories, dependent: :destroy
故事.rb
class Storie < ApplicationRecord
validates :title, :body, :user_id, presence: true
belongs_to :user
如果需要更多信息,请告诉我,我将继续破解它,希望能修复它。