Search code examples
ruby-on-railspluralize

rails can`t pluralize word 'affiche'


I have a model called affiche and model user

class User < ActiveRecord::Base
  has_many :affiches

class Affiche < ActiveRecord::Base
  belongs_to :user

And there i get an error, trying to fetch from db:

uninitialized constant User::Affich

if it didn`t erased the e letter it would be nice, i think.

Is there any way to tell how to pluralize words rails doesn`t know about?


Solution

  • Yes, you can add custom inflection rules in the file config/initializers/inflections.rb. There are examples in that file's comments.