summaryrefslogtreecommitdiff
path: root/app/models/ringtone.rb
diff options
context:
space:
mode:
authorPeter Kozak <spag@golwen.net>2013-02-25 11:41:55 -0500
committerPeter Kozak <spag@golwen.net>2013-02-25 11:41:55 -0500
commitfd07b7b85d2d40d7d2999c2899cc890eda2095fd (patch)
treebf4fbb797d4b645fbe4752a253297a09de466953 /app/models/ringtone.rb
parent0442cd19bc9383669b506185356227361a16e442 (diff)
more polymorphic objects
Diffstat (limited to 'app/models/ringtone.rb')
-rw-r--r--app/models/ringtone.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/app/models/ringtone.rb b/app/models/ringtone.rb
index 36053c0..45ecd93 100644
--- a/app/models/ringtone.rb
+++ b/app/models/ringtone.rb
@@ -1,11 +1,25 @@
class Ringtone < ActiveRecord::Base
attr_accessible :audio, :bellcore_id
+ CORE_RINGTONES_AVAILABLE = {
+ 'Silence' => 0,
+ 'Ringtone 1' => 1,
+ 'Ringtone 2' => 2,
+ 'Ringtone 3' => 3,
+ 'Ringtone 4' => 4,
+ 'Ringtone 5' => 5,
+ 'Ringtone 6' => 6,
+ 'Ringtone 7' => 7,
+ 'Ringtone 8' => 8,
+ 'Ringtone 9' => 9,
+ 'Ringtone 10' => 10,
+ }
mount_uploader :audio, AudioUploader
validates_presence_of :audio, :if => Proc.new{ |ringtone| ringtone.bellcore_id.blank? }
validates_presence_of :ringtoneable_type
validates_presence_of :ringtoneable_id
validates_presence_of :ringtoneable
+ validates_uniqueness_of :ringtoneable_id, :scope => [:ringtoneable_type]
belongs_to :ringtoneable, :polymorphic => true