0

I have a model named Fave. It belongs to another model named User.

I'm trying to find a User's Faves by calling @user.faves. My server gives me back the following error:

NameError: uninitialized constant User::Fafe

Why would it think the singular of "faves" is "fafe"? Is there some other plural form I can use that will point to "fave"?

Joe Morano
  • 1,715
  • 10
  • 50
  • 114

2 Answers2

3

You can pass the class name while setting up the association

has_many :faves, class_name: "Fave"
Deepak Mahakale
  • 22,834
  • 10
  • 68
  • 88
2

Can we try this in config/initializers/inflections.rb? This could work

ActiveSupport::Inflector.inflections do |inflect|
  inflect.irregular 'fave', 'faves' #append this to the existing ones
end
Deepak Mahakale
  • 22,834
  • 10
  • 68
  • 88
Pragun
  • 1,123
  • 8
  • 20
  • This seems likely. I know that the regexp that Rails depends on to find the plural inflection of "sleeve" will return "sleefe" rather than "sleeves." Check out [this answer](http://stackoverflow.com/questions/32337665/table-pluralization/32337815#32337815) for more details on how inflections work in Rails. – MarsAtomic Oct 31 '16 at 04:03