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