diff options
author | Stefan Wintermeyer <stefan.wintermeyer@amooma.de> | 2013-03-10 08:45:30 +0100 |
---|---|---|
committer | Stefan Wintermeyer <stefan.wintermeyer@amooma.de> | 2013-03-10 08:45:30 +0100 |
commit | e2a03b5d20253d7a1eb10b8c110d9feec79e995f (patch) | |
tree | cc36cbb2572e549ce59388654d358cb1e2771ecd /app/models/switchboard_entry.rb | |
parent | 595a48a91f8549b20109942e0b80df4f891d5999 (diff) | |
parent | 21d0843117c0962bd962fc50fccaf276a5b3067f (diff) |
Fixed a merging conflict.
Merge branch 'switchboard' into develop
Conflicts:
app/models/sip_account.rb
Diffstat (limited to 'app/models/switchboard_entry.rb')
-rw-r--r-- | app/models/switchboard_entry.rb | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/app/models/switchboard_entry.rb b/app/models/switchboard_entry.rb new file mode 100644 index 0000000..76d002f --- /dev/null +++ b/app/models/switchboard_entry.rb @@ -0,0 +1,31 @@ +class SwitchboardEntry < ActiveRecord::Base + # https://github.com/rails/strong_parameters + include ActiveModel::ForbiddenAttributesProtection + + belongs_to :switchboard, :touch => true + belongs_to :sip_account, :touch => true + + validates :switchboard, + :presence => true + + validates :sip_account, + :presence => true + + validates :name, + :length => { :maximum => 10 }, + :uniqueness => {:scope => :switchboard_id}, + :allow_blank => true, + :allow_nil => true + + acts_as_list :scope => [ :switchboard_id ] + + default_scope order(:position) + + def to_s + if self.name.blank? && !self.sip_account.to_s.blank? + self.sip_account.to_s + else + self.name.to_s + end + end +end |