I have been using MongoMapper with Rails 5.2. Creating model:
class Item
include MongoMapper::Document
key :title, String
key :description, String
end
In the MongoDB, I inserted the document
{
"title": "demo",
"description": "this is the demo item"
}
Using Rails console to test this model
Item.where({:title => "demo"}).first
It shows the result is the document above. But when I create a new document with:
item = Item.create({:title => "demo2", :description => "the demo2"})
An error in the console
Traceback (most recent call last):
2: from (irb):3
1: from (eval):9:in `title='
NoMethodError (undefined method `[]' for nil:NilClass)
I tried with the method new
item = Item.new
The console shows:
Traceback (most recent call last):
2: from (irb):4
1: from (irb):4:in `new'
NoMethodError (undefined method `keys' for nil:NilClass)
Please help!
Mongomapper is not compatible with rails 5.2