A Ruby ORM for RethinkDB


Model Declaration

To create a model with NoBrainer, simply include the NoBrainer::Document mixin in your class as such:

class User
  include NoBrainer::Document

There is no migrations needed to use the model since NoBrainer creates the required tables for you by default.

The default table name is'/', '__'). You may change the table name as described in the Multi Tenancy section.

Polymorphic Models

To use polymorphic models with single table inheritance, simply inherit your classes. Example:

class Admin < User

NoBrainer uses a _type attribute in the subclass documents to be able to query and instantiate the proper classes.

Note that when using Rails, you might have to use require_dependency to ensure that all subclasses are loaded. See more in the Rails guide, Autoloading and STI.


Sometimes it’s useful to go through all the models to do something fancy. The list of models can be retrieved with NoBrainer::Document.all. When using polymorphism, note that subclasses are not returned, only root classes.