Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails LoadError-无法自动加载常量_Ruby On Rails_Ruby_Ruby On Rails 5.2 - Fatal编程技术网

Ruby on rails LoadError-无法自动加载常量

Ruby on rails LoadError-无法自动加载常量,ruby-on-rails,ruby,ruby-on-rails-5.2,Ruby On Rails,Ruby,Ruby On Rails 5.2,仅在开发环境中,我经常会遇到以下错误。我试着用谷歌搜索几个解决方案,但没有一个对我有效。我相信我已经遵循了命名惯例。有人能看看吗 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'

仅在开发环境中,我经常会遇到以下错误。我试着用谷歌搜索几个解决方案,但没有一个对我有效。我相信我已经遵循了命名惯例。有人能看看吗

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\u 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

你在
/home/aniket/my_project/app/models/payments/promo_code.rb中有什么?@mrzasa一些关联、验证、枚举、回调和一些方法可以粘贴此文件的前几行吗?也就是那些定义模块和类的东西。@mrzasa我已经更新了一些东西。没有想法,这很奇怪
class Ability
  include CanCan::Ability

  def initialize(user, session = nil)
    can :manage, Payments::PromoCode
  end
end