Search code examples
ruby-on-railsnaming-conventionscamelcasing

Rails thinks "faves" is referring to a model named "Fafe"


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"?


Solution

  • You can pass the class name while setting up the association

    has_many :faves, class_name: "Fave"