cs_app/app/models/image_content.rb
Nicolas Bally 8a08ee35c8 initial
2015-02-22 14:36:30 +01:00

36 lines
720 B
Ruby

# -*- encoding : utf-8 -*-
class ImageContent < ActiveRecord::Base
belongs_to :image_file
has_one :portlet, :as => :content, :dependent => :destroy
STYLES = [["Grande","5"],["Taille moyenne","1"], ["Petite taille","2"], ["Petit carré","3"], ["Miniature","4"],["Orginale","6"]]
ALIGNS = [["centré","center"], ["gauche","left"],["droite","right"],["Aucun","none"]]
belongs_to :cible, :polymorphic => true
accepts_nested_attributes_for :cible
before_validation do
if !self.with_cible
self.cible_type = nil
self.cible_id = nil
end
end
def url
if self.cible
cible.url
else
""
end
end
def self.picto
"picture-o"
end
end