Jeffrey C Jeffrey C - 1 month ago 9
Ruby Question

Where can I find a specific documentation for a Mongoid class?

I am new to Mongoid and I want to learn more about it. Today I came across

Mongoid::Timestamps
in here .

It looks interesting to me so I wanted to know more about it, but could not find any more documentation on
Mongoid::Timestamps
. I've currently tried searching here, in Class List, Method List and File List, but didn't find anything.

Seems like Mongoid has a very limited documentation.

Answer

You can read its RubyDoc to find more about Mongoid::Timestamps. It's nothing special, but in a nutshell:

Including Mongoid::Timestamps in your Ruby model classes would tell MongoDB to save timestamps of when a document was created or updated. This creates two new attributes in your model:

  • created_at
  • updated_at

You use it like this:

class User
  include Mongoid::Document
  include Mongoid::Timestamps

  # Other stuff...
end
Comments