class Banner include Mongoid::Document include Mongoid::Timestamps include OrbitTag::Taggable include OrbitCategory::Categorizable field :ad_fx, type: String field :height, type: Integer field :speed, type: Integer field :title, type: String field :timeout, type: Integer field :width, type: Integer has_many :ad_images , dependent: :delete validates_uniqueness_of :title validates :title, :length => { :minimum => 2 } validates :height, :width, :presence => true FX_TYPES = %w(fade fadeout flipHorz flipVert scrollHorz scrollVert tileSlide tileBlind) def size "#{self.width} x #{self.height}" end def timeout_millisecond self.timeout*1000 rescue 0 end def preview_link "Preview".html_safe end def data_attribute_hash {'width'=> self.width,'height'=> self.height,'ad_fx'=> self.ad_fx,'name'=>self.title,'timeout'=>self.timeout,'speed'=>self.speed}.to_json end end