Class: CeilingInsulationType

Inherits:
ApplicationRecord show all
Includes:
Models::Auditable
Defined in:
app/models/ceiling_insulation_type.rb

Overview

== Schema Information

Table name: ceiling_insulation_types
Database name: primary

id :integer not null, primary key
name :string(255)
u_value :float
ceiling_type_id :integer

Indexes

ceiling_insulation_types_ceiling_type_id_idx (ceiling_type_id)

Foreign Keys

ceiling_insulation_types_ceiling_type_id_fk (ceiling_type_id => ceiling_types.id)

Constant Summary

Constants included from Models::Auditable

Models::Auditable::ALWAYS_IGNORED

Belongs to collapse

Methods included from Models::Auditable

#creator, #updater

Class Method Summary collapse

Methods included from Models::Auditable

#all_skipped_columns, #audit_reference_data, #should_not_save_version, #stamp_record

Methods inherited from ApplicationRecord

ransackable_associations, ransackable_attributes, ransackable_scopes, ransortable_attributes, #to_relation

Methods included from Models::EventPublishable

#publish_event

Class Method Details

.by_ceiling_type_idActiveRecord::Relation<CeilingInsulationType>

A relation of CeilingInsulationTypes that are by ceiling type id. Active Record Scope

Returns:

See Also:



26
# File 'app/models/ceiling_insulation_type.rb', line 26

scope :by_ceiling_type_id, ->(id) { where(:ceiling_type_id => id) }

.by_u_valueActiveRecord::Relation<CeilingInsulationType>

A relation of CeilingInsulationTypes that are by u value. Active Record Scope

Returns:

See Also:



25
# File 'app/models/ceiling_insulation_type.rb', line 25

scope :by_u_value, -> { order("ceiling_insulation_types.u_value DESC") }

.options_for_select(ceiling_type_id, rc) ⇒ Object



28
29
30
31
32
# File 'app/models/ceiling_insulation_type.rb', line 28

def self.options_for_select(ceiling_type_id, rc)
  res = CeilingInsulationType.by_ceiling_type_id(ceiling_type_id).map{|o| [o.name.titleize, o.id]}
  res = [["Please Choose What's Over The Ceiling", nil]] if res.empty?
  return res
end

Instance Method Details

#ceiling_typeCeilingType



23
# File 'app/models/ceiling_insulation_type.rb', line 23

belongs_to :ceiling_type, optional: true