Sha256: 3e87cd4889c966ca1e832ddf29d2f31dde77b4c4b3ac86905727f44d30181e77

Contents?: true

Size: 1.89 KB

Versions: 2

Compression:

Stored size: 1.89 KB

Contents

module C80Yax
  class MainProp < ActiveRecord::Base
    belongs_to :strsubcat
    has_and_belongs_to_many :prop_names

    include C80Yax::Concerns::Props::Parsable

    # выдать таблицу, которая описывает список свойств, которые выводятся справа от картинки
    # +--------------+--------------+--------------+---------------------------+-----------+
    # | strsubcat_id | main_prop_id | prop_name_id | title                     | uom_title |
    # +--------------+--------------+--------------+---------------------------+-----------+
    # |            1 |            1 |           23 | Размер                    | NULL      |
    # |            1 |            2 |           27 | Марка по морозостойкости  | NULL      |
    # |            1 |            3 |           33 | Вес                       | кг        |
    # |            1 |            4 |           28 | Водопоглощение            | %         |
    # +--------------+--------------+--------------+---------------------------+-----------+

    def self.select_props_sql(strsubcat_id)
      Rails.logger.debug "[TRACE] <MainProp.select_props_sql> strsubcat_id = #{strsubcat_id}"
      sql = "
      SELECT
        c80_yax_main_props.strsubcat_id,
        c80_yax_main_props_prop_names.*,
        c80_yax_prop_names.title,
        c80_yax_uoms.title as uom_title
      FROM c80_yax_main_props
        LEFT JOIN c80_yax_main_props_prop_names ON c80_yax_main_props.id = c80_yax_main_props_prop_names.main_prop_id
        LEFT JOIN c80_yax_prop_names ON c80_yax_main_props_prop_names.prop_name_id = c80_yax_prop_names.id
        LEFT JOIN c80_yax_uoms ON c80_yax_prop_names.uom_id = c80_yax_uoms.id
      WHERE c80_yax_main_props.strsubcat_id = #{strsubcat_id};
    "
      rows = ActiveRecord::Base.connection.execute(sql)
      rows
    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
c80_yax-0.1.0.4 app/models/c80_yax/main_prop.rb
c80_yax-0.1.0.3 app/models/c80_yax/main_prop.rb