summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
Diffstat (limited to 'app/models')
-rw-r--r--app/models/parking_stall.rb14
-rw-r--r--app/models/tenant.rb2
-rw-r--r--app/models/user.rb2
3 files changed, 18 insertions, 0 deletions
diff --git a/app/models/parking_stall.rb b/app/models/parking_stall.rb
index 52223a8..6af1fcd 100644
--- a/app/models/parking_stall.rb
+++ b/app/models/parking_stall.rb
@@ -1,3 +1,17 @@
class ParkingStall < ActiveRecord::Base
attr_accessible :name, :lot, :parking_stallable_id, :parking_stallable_type, :comment
+
+ belongs_to :parking_stallable, :polymorphic => true, :touch => true
+
+ validates :name,
+ :presence => true,
+ :uniqueness => true
+
+ validates :lot,
+ :presence => true
+
+ def to_s
+ name.to_s
+ end
+
end
diff --git a/app/models/tenant.rb b/app/models/tenant.rb
index 419ac3a..0622f52 100644
--- a/app/models/tenant.rb
+++ b/app/models/tenant.rb
@@ -39,6 +39,8 @@ class Tenant < ActiveRecord::Base
has_many :automatic_call_distributors, :as => :automatic_call_distributorable, :dependent => :destroy
has_many :acd_agents, :through => :automatic_call_distributors
+ has_many :parking_stalls, :as => :parking_stallable, :dependent => :destroy
+
# Phone numbers of the tenant.
#
has_many :phone_number_ranges_phone_numbers, :through => :phone_number_ranges, :source => :phone_numbers, :readonly => true
diff --git a/app/models/user.rb b/app/models/user.rb
index afb3f04..fdcd617 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -87,6 +87,8 @@ class User < ActiveRecord::Base
validate :current_tenant_is_included_in_tenants, :if => Proc.new{ |user| user.current_tenant_id }
belongs_to :gs_node
+
+ has_many :parking_stalls, :as => :parking_stallable, :dependent => :destroy
# Avatar like photo
mount_uploader :image, ImageUploader