I have a data model which has the name ‘rack’. When I generate a model with this name in my Rails project, I get errors when launching the server.
load_missing_constant: uninitialized constant ActiveRecord (NameError)
I am not using Rack Middleware and I don’t see ‘rack’ as a reserved word in Ruby or Rails. Is there something I’m missing here?
Well, if you’re using a recent version of Rails, you actually are using Rack middleware, since that’s how several Rails components are implemented these days (Rails as a whole is, in fact, a Rack application now). As such, there’s already a constant named Rack, so when you try to create an ActiveRecord model called Rack, there’s a collision. I’m not sure why you get that particular error, though – when I tried it on a toy project, I got this error trying to run the migration:
Regardless, I strongly suspect that this is the underlying cause of your problem. Would it be possible to change the name of your model?