Skip to content

Instantly share code, notes, and snippets.

@mattconnolly
Forked from ltw/best_model.rb
Created February 16, 2014 23:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattconnolly/9042186 to your computer and use it in GitHub Desktop.
Save mattconnolly/9042186 to your computer and use it in GitHub Desktop.
class Model < ParentModel
include Foo::Bar
extend Bar::Baz
acts_as_authentic
dsl_specific_flags
module InternalModule
...
end
default_scope :order => 'id ASC'
belongs_to :foo
has_one :baz
has_many :bars
has_many :maz, :through => :daz
has_and_belongs_to_many :jaz
serialize :bars, Hash
...
before_validation :foo
after_validation :bar
before_save :baz
before_create :taz
after_create :daz
after_save :maz
after_commit :laz
...
validates_presence_of :id
validates_uniqueness_of :id
validates_inclusion_of :rating, :in => [1..10]
validates_numericality_of :taz
...
accepts_nested_attributes_for :foobar
scope :by_name, :order => 'name ASC'
scope :lambda_scope, :lambda => { |lambda| { ... } }
...
attr_reader :foobaz
attr_accessor :foobar
delegate :barbaz, :to => :foo
...
def self.class_method
end
def instance_method
end
protected
def self.class_method
end
def instance_method
end
private
def self.class_method
end
def instance_method
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment