beagle_app/app/models/img_link_content.rb
Nicolas Bally 7b6cba2128 initial
2015-01-27 23:13:36 +01:00

40 lines
633 B
Ruby

# -*- encoding : utf-8 -*-
class ImgLinkContent < ActiveRecord::Base
belongs_to :image_file
belongs_to :item
belongs_to :cible, :polymorphic => true
has_one :portlet, :as => :content, :dependent => :destroy
validates :title, :presence => true
accepts_nested_attributes_for :cible, :reject_if => lambda { |a| 1 == 1 }
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
STYLES = [["Style 1",1], ["Style 2",2]]
def self.picto
"cloud-download"
end
end