Class: UnderFloorInsulationType

Inherits:
ApplicationRecord show all
Defined in:
app/models/under_floor_insulation_type.rb

Overview

== Schema Information

Table name: under_floor_insulation_types
Database name: primary

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

Indexes

under_floor_insulation_types_under_floor_type_id_idx (under_floor_type_id)

Foreign Keys

under_floor_insulation_types_under_floor_type_id_fk (under_floor_type_id => under_floor_types.id)

Constant Summary

Constants included from Models::Schedulable

Models::Schedulable::SIMPLE_FORM_OPTIONS

Belongs to collapse

Class Method Summary collapse

Methods inherited from ApplicationRecord

ransackable_associations, ransackable_attributes, ransackable_scopes, ransortable_attributes, #to_relation

Methods included from Models::Schedulable

config

Methods included from Models::AfterCommittable

#after_commit

Methods included from Models::EventPublishable

#publish_event

Class Method Details

.by_u_valueActiveRecord::Relation<UnderFloorInsulationType>

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

Returns:

See Also:



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

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

.by_under_floor_type_idActiveRecord::Relation<UnderFloorInsulationType>

A relation of UnderFloorInsulationTypes that are by under floor type id. Active Record Scope

Returns:

See Also:



24
# File 'app/models/under_floor_insulation_type.rb', line 24

scope :by_under_floor_type_id, ->(id) { where(under_floor_type_id: id) }

.options_for_select(under_floor_type_id, _rc) ⇒ Array<Array(String, Integer)>

Parameters:

  • under_floor_type_id (Integer)
  • _rc (Object)

    unused

Returns:

  • (Array<Array(String, Integer)>)


29
30
31
32
33
# File 'app/models/under_floor_insulation_type.rb', line 29

def self.options_for_select(under_floor_type_id, _rc)
  res = UnderFloorInsulationType.by_under_floor_type_id(under_floor_type_id).map { |o| [o.name.titleize, o.id] }
  res = [["Please Choose What's Under The Floor", nil]] if res.empty?
  res
end

Instance Method Details

#under_floor_typeUnderFloorType?

Returns:



21
# File 'app/models/under_floor_insulation_type.rb', line 21

belongs_to :under_floor_type, optional: true