Sha256: b8e2c31f5abcb2a8f240b8084e6acc1da223c0b731b8b19b9d33e886e139f531
Contents?: true
Size: 1.99 KB
Versions: 2
Compression:
Stored size: 1.99 KB
Contents
module C80Estate class Property < ActiveRecord::Base belongs_to :atype belongs_to :owner, :polymorphic => true belongs_to :assigned_person, :polymorphic => true has_many :item_props, :dependent => :destroy has_many :pphotos, :dependent => :destroy # одна или несколько фоток accepts_nested_attributes_for :pphotos, :reject_if => lambda { |attributes| !attributes.present? }, :allow_destroy => true has_many :plogos, :dependent => :destroy # одна или несколько фоток accepts_nested_attributes_for :plogos, :reject_if => lambda { |attributes| !attributes.present? }, :allow_destroy => true has_many :areas, :dependent => :destroy has_many :comments, :dependent => :destroy has_many :sevents, :dependent => :destroy has_many :pstats, :dependent => :destroy def assigned_person_title res = "-" if assigned_person.present? res = assigned_person.email end res end def owner_title res = "-" if owner.present? res = owner.email end res end def logo_path url = 'property_default_logo.png' if plogos.count > 0 url = plogos.first.image.thumb256 end url end def main_image_url url = 'no_thumb.png' if pphotos.count > 0 url = pphotos.first.image.thumb512 end url end def last_updater pstats.last.sevent.auser.email end def square_value sum = 0 areas.all.each do |area| sum += area.square_value end sum end def power_price_value sum = 0 areas.all.each do |area| sum += area.power_price_value end sum end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
c80_estate-0.1.0.19 | app/models/c80_estate/property.rb |
c80_estate-0.1.0.18 | app/models/c80_estate/property.rb |