summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
Diffstat (limited to 'app/models')
-rw-r--r--app/models/call_route.rb2
-rw-r--r--app/models/switchboard.rb14
-rw-r--r--app/models/user.rb2
3 files changed, 17 insertions, 1 deletions
diff --git a/app/models/call_route.rb b/app/models/call_route.rb
index 8bc811a..6c54549 100644
--- a/app/models/call_route.rb
+++ b/app/models/call_route.rb
@@ -7,7 +7,7 @@ class CallRoute < ActiveRecord::Base
has_many :route_elements, :dependent => :destroy, :order => :position
validates :name,
- :presence => true
+ :presence => true
validates :routing_table,
:presence => true,
diff --git a/app/models/switchboard.rb b/app/models/switchboard.rb
new file mode 100644
index 0000000..cb0c70f
--- /dev/null
+++ b/app/models/switchboard.rb
@@ -0,0 +1,14 @@
+class Switchboard < ActiveRecord::Base
+ # https://github.com/rails/strong_parameters
+ include ActiveModel::ForbiddenAttributesProtection
+
+ validates :name,
+ :presence => true,
+ :uniqueness => {:scope => :user_id}
+
+ belongs_to :user, :touch => true
+
+ def to_s
+ self.name.to_s
+ end
+end
diff --git a/app/models/user.rb b/app/models/user.rb
index 913d75f..6091e32 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -94,6 +94,8 @@ class User < ActiveRecord::Base
has_many :group_memberships, :as => :item, :dependent => :destroy, :uniq => true
has_many :groups, :through => :group_memberships
+ has_many :switchboards, :dependent => :destroy
+
# Avatar like photo
mount_uploader :image, ImageUploader