[DataMapper] datamapper undefined method `include?' for nil:NilClass

Tadashi Shigeoka ·  Mon, December 12, 2011

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

・Source: DataMapper - Getting started with DataMapper

I should have read the documentation properly before starting to use it…

That’s all from the Gemba.

【References】

#159: undefined method `include?’ for nil:NilClass in 1.2.0 but not 1.1.0 - Issues - datamapper/dm-core - GitHub

The Future is Now: DataMapper.finalize