Class: Risk
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Risk
- Defined in:
- app/models/risk.rb
Overview
This model manage the risks of work
Relations
has many CategoryRisk has many Category, through CategoryRisk
Validates
Default scope
-
order by title asc
Instance Attribute Summary collapse
-
#code ⇒ String
Short code of Risk.
-
#created_at ⇒ DateTime
When the record was created.
-
#id ⇒ Integer
Unique identifier for Risk.
-
#printed ⇒ Boolean
If Risk enter in the reports, can’t be null, default is true.
-
#title ⇒ String
Full title of Risk, can’t be null, default is empty string.
-
#updated_at ⇒ DateTime
When the record was updated.
Class Method Summary collapse
-
.printed ⇒ Array
All Risk with Risk.printed true, order by code.
Methods inherited from ApplicationRecord
Instance Attribute Details
#code ⇒ String
Returns Short code of Risk.
28 29 30 31 32 33 34 35 36 37 |
# File 'app/models/risk.rb', line 28 class Risk < ApplicationRecord has_many :category_risks, dependent: :restrict_with_exception has_many :categories, through: :category_risks validates :title, presence: true, uniqueness: true default_scope { order('title asc') } scope :printed, -> { unscoped.where(printed: true).order(:code) } end |
#created_at ⇒ DateTime
Returns when the record was created.
28 29 30 31 32 33 34 35 36 37 |
# File 'app/models/risk.rb', line 28 class Risk < ApplicationRecord has_many :category_risks, dependent: :restrict_with_exception has_many :categories, through: :category_risks validates :title, presence: true, uniqueness: true default_scope { order('title asc') } scope :printed, -> { unscoped.where(printed: true).order(:code) } end |
#id ⇒ Integer
Returns unique identifier for Risk.
28 29 30 31 32 33 34 35 36 37 |
# File 'app/models/risk.rb', line 28 class Risk < ApplicationRecord has_many :category_risks, dependent: :restrict_with_exception has_many :categories, through: :category_risks validates :title, presence: true, uniqueness: true default_scope { order('title asc') } scope :printed, -> { unscoped.where(printed: true).order(:code) } end |
#printed ⇒ Boolean
Returns if Risk enter in the reports, can’t be null, default is true.
28 29 30 31 32 33 34 35 36 37 |
# File 'app/models/risk.rb', line 28 class Risk < ApplicationRecord has_many :category_risks, dependent: :restrict_with_exception has_many :categories, through: :category_risks validates :title, presence: true, uniqueness: true default_scope { order('title asc') } scope :printed, -> { unscoped.where(printed: true).order(:code) } end |
#title ⇒ String
Returns full title of Risk, can’t be null, default is empty string.
28 29 30 31 32 33 34 35 36 37 |
# File 'app/models/risk.rb', line 28 class Risk < ApplicationRecord has_many :category_risks, dependent: :restrict_with_exception has_many :categories, through: :category_risks validates :title, presence: true, uniqueness: true default_scope { order('title asc') } scope :printed, -> { unscoped.where(printed: true).order(:code) } end |
#updated_at ⇒ DateTime
Returns when the record was updated.
28 29 30 31 32 33 34 35 36 37 |
# File 'app/models/risk.rb', line 28 class Risk < ApplicationRecord has_many :category_risks, dependent: :restrict_with_exception has_many :categories, through: :category_risks validates :title, presence: true, uniqueness: true default_scope { order('title asc') } scope :printed, -> { unscoped.where(printed: true).order(:code) } end |
Class Method Details
.printed ⇒ Array
28 29 30 31 32 33 34 35 36 37 |
# File 'app/models/risk.rb', line 28 class Risk < ApplicationRecord has_many :category_risks, dependent: :restrict_with_exception has_many :categories, through: :category_risks validates :title, presence: true, uniqueness: true default_scope { order('title asc') } scope :printed, -> { unscoped.where(printed: true).order(:code) } end |