Uninitialized Constant Model When Plural Is The Same As Singular
Posted by Weston Ganger
I found it to be a major pain in the ass when a model name’s plural version is the same as singular(ex. Equipment)
I was getting wierd ‘unitialized constant’ errors when trying to call the model name which. This error was occuring in Rails 3.2 so it probably works better in newer versions of rails.
The solution is to force the namespacing like so:
@equipment = ::Equipment.find(params[:equipment_id])
The two colans(::) in front of the model name tells it to use the global namespace rather than the current namespace.
Related External Links: