LoadError-无法自动加载常量

仅在开发环境中,我经常经常遇到以下错误。我尝试用谷歌搜索一些解决方案,但对我没有用。而且我相信我已经遵循了命名约定。有人可以看看吗

LoadError - Unable to autoload constant Payments::PromoCode,expected /home/aniket/my_project/app/models/payments/promo_code.rb to define it:
  app/models/ability.rb:649:in `initialize'
  app/controllers/application_controller.rb:245:in `user_info'
  app/controllers/application_controller.rb:239:in `user_list'
  app/middleware/skip_trackable.rb:8:in `call'

文件 promo_code.rb

module Payments
  class PromoCode < ApplicationRecord
    has_many :user_settings
    has_many :users,through: :user_settings

    enum type: %w(value distinction)

    validates :type,inclusion: { in: Payments::PromoCode::type.keys},allow_blank: true
  end
end

能力

class Ability
  include CanCan::Ability

  def initialize(user,session = nil)
    can :manage,Payments::PromoCode
  end
end
alishar 回答:LoadError-无法自动加载常量

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3095236.html

大家都在问