Normal validations
- Favour putting these into a Form Object once it becomes anything but the simplest example
Regular relationships (has_many, belongs_to etc)
def set_published!
self.published = true
self.save!
end
Predicate methods and the like, for example
def bought_as_gift?
payers.any? # payers is a relationship
end
Methods which do queries, for example
def self.newest_member
where('member_id IS NOT NULL').order('created_at').last
end
This allows you to stub just the method #newest_member
and more accurately models the domain
Don't use #where
outside of ActiveRecord classes
Methods which just create object instances and save
def self.create_user!(email)
create!(email: email, subscribed: true)
end