Skip to content
Pedro Belo edited this page Aug 6, 2015 · 5 revisions

Pliny models are just like Rails', only using Sequel::Model instead of ActiveRecord. Use them to wrap access to database.

You should try keep models lean. Think of them as pure data objects: every single method in a model should only return data that came from the database or was generated from another static source. They should not manipulate data, interact with other models, make API requests, etc – Mediators are a much better fit for these.

To get a new model:

$ pliny-generate model todo
created model file ./lib/models/todo.rb
created migration ./db/migrate/1408995997_create_todos.rb
created test ./spec/models/todo_spec.rb