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)

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::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) ⇒ Object



26
27
28
29
30
# File 'app/models/under_floor_insulation_type.rb', line 26

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?
  return res
end

Instance Method Details

#under_floor_typeUnderFloorType



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

belongs_to :under_floor_type, optional: true