-
Notifications
You must be signed in to change notification settings - Fork 33
Models
You can use anything you like as a model – a plain Ruby class, ActiveRecord with Sqlite3 or SuperModel.
SuperModel is Bowline’s default option, due to the fact that using ActiveRecord is often overkill for Bowline projects. SuperModel stores all the app’s data in-memory, which you can usually afford to do if the data isn’t large.
You can generate a model using bowline-gen, e.g:
bowline-gen model tweet
This will generate a model in:
app/models/tweet.rb
SuperModel is an in-memory database library. It’s built on top of ActiveModel – so you get all the benefits, such as Callbacks, Observers, Validation and even Associations. Check out the library’s README for more information.
SuperModel can marshal your model data to disk, persisting it. To enable this, just include the SuperModel::Marshal::Model module, e.g.:
class Tweet < SuperModel::Base
include SuperModel::Marshal::Model
end