From fd07b7b85d2d40d7d2999c2899cc890eda2095fd Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Mon, 25 Feb 2013 11:41:55 -0500 Subject: more polymorphic objects --- app/models/ringtone.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'app/models/ringtone.rb') 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 -- cgit v1.2.3