To create a model with NoBrainer, simply include the
in your class as such:
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.
To use polymorphic models with single table inheritance, simply inherit your classes. Example:
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
When using polymorphism, note that subclasses are not returned, only root classes.