NameError: uninitialized constant (rails)

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

I have a simple model called PhoneNumber:

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


        
10条回答
  •  -上瘾入骨i
    2020-12-24 05:57

    If none of the above work, I also have a different approach, as it happened to me in a real scenario.

    More specifically using auto-generated Ruby files from Thrift.


    In my situation, I had a Module with several classes, so the order is important in this case:

    Class A makes use of Class B in the same module. However, Class B was declared after Class A.

    Simply making Class B to be declared before Class A solved the issue to me.

提交回复
热议问题