Skip to content

Instantly share code, notes, and snippets.

@AquisTech
Last active November 15, 2020 03:48
Show Gist options
  • Save AquisTech/2de18747be681c037c00d26758e25273 to your computer and use it in GitHub Desktop.
Save AquisTech/2de18747be681c037c00d26758e25273 to your computer and use it in GitHub Desktop.
Order of elements arrangement in Model
# encoding
class ModelName < ApplicationRecord
# require statements
# extend Modules
# include Modules
# Gem/Plugins options
# CONSTANTS
# Attribute accessors
# serialize attributes
# validations
# Callbacks
# before_validation
# after_validation
# before_save
# around_save
# Creating an Object
# before_create
# around_create
# after_create
# Updating an Object
# before_update
# around_update
# after_update
# after_save
# Destroying an Object
# before_destroy
# around_destroy
# after_destroy
# After manipulation (success/failure)
# after_commit
# after_rollback
# Associations
# belongs_to
# polymorphic
# has_one
# has_many (simple)
# has_many (using :through)
# Association configurations such as 'accepts_nested_attributes_for' statements
# Delegates
# Scopes
# Class Methods
# Getter setter
# Instance Methods (used in validation blocks)
# Instance Methods
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment