NameError: uninitialized constant (rails)

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

    I had this problem because I changed the name of the class in a model, and it did not match the name of the file.

    "Model class names use CamelCase. These are singular, and will map automatically to the plural database table name.

    Model files go in app/models/#{singular_model_name}.rb."

    https://gist.github.com/iangreenleaf/b206d09c587e8fc6399e#model

提交回复
热议问题