I have a controller named User. In two of its actions, I would like to access a model named Preference. I receive an “uninitialized constant UserController::Preferences” error when trying to tap either action.
I am able to access other models such as Prospect without error. Both Prospect and Preference are related have a belongs_to relationship with User.
I’ve tried accessing the model as ::Preferences, but I receive this very similar error: “uninitialized constant Preferences”. I’ve also tried manually requiring the model, to no avail.
Has anyone else run into this problem and come up with a solution?
It looks like you are calling it “Preferences”. But that is almost certainly not the name of your model.
Note that when we call Preference, it is singular.