NameError: uninitialized constant (rails)

后端 未结 10 799
一向
一向 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:06

    Some things to try:

    1. Restart the rails console; changes to your models will only get picked up by a rails console that is already open if you do > reload! (although I have found this to be unpredictable), or by restarting the console.

    2. Is your model file called "phone_number.rb" and is it in "/app/models"?

    3. You should double-check the "--sandbox" option on your rails console command. AFAIK, this prevents changes. Try it without the switch.

提交回复
热议问题