[DataMapper] datamapper undefined method `include?' for nil:NilClass
When saving data to the database with Sinatra + DataMapper, the following error occurred:
datamapper undefined method `include?' for nil:NilClass
The code I wrote was using methods like new, create that should exist on the Model, but I was getting errors saying they weren’t defined.
The cause seems to be that I hadn’t performed the finalization process after declaring the models.
When I looked into it, it was properly documented in the DataMapper official documentation.
Finalize Models
After declaring all of the models, you should finalize them:
DataMapper.finalize
I should have read the documentation properly before starting to use it…
That’s all from the Gemba.
【References】