NameError: uninitialized constant (rails)

后端 未结 10 785
一向
一向 2020-12-24 05:52

I have a simple model called PhoneNumber:

class PhoneNumber < ActiveRecord::Base
  validates :pnumber, presence: true, on: :create #=> { :message =>         


        
10条回答
  •  庸人自扰
    2020-12-24 06:11

    I ran into this also with a file directly in the models directory, and it turns out that I wasn't properly loading up the code on startup. I was able to fix the issue by setting config.eager_load = true in my development.rb file. This made the class available to me in the console

提交回复
热议问题