Take the 2-minute tour ×

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?

share|improve this question

2 Answers 2

up vote 4 down vote accepted

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

share|improve this answer
Thank you, that worked fine! –  M2_ Oct 11 '11 at 21:58

You can specify the class name of the children as an option to has_many. Something like:

class User < ActiveRecord::Base
  has_many :affiches, class_name: 'Affiche'

See http://apidock.com/rails/v4.0.2/ActiveRecord/Associations/ClassMethods/has_many for further examples.

share|improve this answer

Your Answer


