[RUBY] Define multiple names for a model NameError (uninitialized constant User :: Reserf):

environment

MacBook Air2020 Ruby2.7.1 Rails6.0.3.4 MySQL

Introduction

It seems that the plural definition of the reserve model automatically becomes reserf It was discovered by an error message.

NameError (uninitialized constant User::Reserf):

Solution

I was able to solve it by defining the plural as follows.

config/initializers/inflections.rb


ActiveSupport::Inflector.inflections(:en) do |inflect|
  inflect.irregular "reserve", "reserves"
end

Recommended Posts

Define multiple names for a model NameError (uninitialized constant User :: Reserf):
Rails uninitialized constant A simple checklist for error resolution
Resolve NameError: uninitialized constant [Action Mailer]