I have a model named Engine, and I am able to use it in views and controllers without issues.
The problem occurs when I use it in a model (for example, in callbacks or even simple instance methods).
#inside the vehicle model
def add_engines
Engine.all.each do |ngin|
...
end
I get the error: NoMethodError: undefined method 'all' for #<Some_mounted_engine_name:0x00000103b48828>
I search the web, but I do not see Engine as a reserved word. Note that we use mounted engines in our app.
I think you’re running into Ruby scoping issues. Try
::Engineinstead ofEngine– you’re probably implicitly referring toRails::Engine