Class: C80Catoffers::Csample

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/c80_catoffers/csample.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.all_widgetedObject

выдать список тех Примеров, которые должны выводиться в виджете



30
31
32
# File 'app/models/c80_catoffers/csample.rb', line 30

def self.all_widgeted
  self.joins(:csprops)
end

Instance Method Details

#csphoto_imgObject



34
35
36
37
# File 'app/models/c80_catoffers/csample.rb', line 34

def csphoto_img
  self.csphoto.present? ? MiniMagick::Image.open(self.csphoto.path):nil
  # [img["width"],img["height"]]
end

#recalc_summ_priceObject



17
18
19
20
21
22
23
24
25
26
27
# File 'app/models/c80_catoffers/csample.rb', line 17

def recalc_summ_price

  sum = crows.all
            .map { |crow| crow.offer_price_integer.to_i }
            .inject(0) { |s, x| s + x }

  Rails.logger.debug "[TRACE] <C80Catoffers.recalc_summ_price> sum = #{sum}"

  self.update_column(:summ_price, sum)

end