app/models/c80_estate/property.rb in c80_estate-0.1.0.24 vs app/models/c80_estate/property.rb in c80_estate-0.1.0.25
- old
+ new
@@ -1,11 +1,11 @@
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 :item_props, :dependent => :destroy
has_many :pphotos, :dependent => :destroy # одна или несколько фоток
accepts_nested_attributes_for :pphotos,
:reject_if => lambda { |attributes|
!attributes.present?
},
@@ -60,27 +60,27 @@
# 0
# end
# end
def average_price
- price_sum = 0
+ price_sum = 0.0
areas.all.each do |area|
price_sum += area.price_value
end
if areas.all.count != 0
price_sum*1.0 / areas.all.count
else
- 0
+ 0.0
end
end
def average_price_busy
busy_areas_count = 0
- price_sum = 0
+ price_sum = 0.0
areas.all.each do |area|
if area.is_busy?
busy_areas_count += 1
price_sum += area.price_value
@@ -88,11 +88,11 @@
end
if busy_areas_count != 0
price_sum*1.0 / busy_areas_count
else
- 0
+ 0.0
end
end
def assigned_person_title
@@ -133,18 +133,18 @@
res = pstats.last.sevent.auser.email
end
end
def square_value
- sum = 0
+ sum = 0.0
areas.all.each do |area|
sum += area.square_value
end
sum
end
def power_price_value
- sum = 0
+ sum = 0.0
areas.all.each do |area|
sum += area.power_price_value
end
sum
end
\ No newline at end of file