56 lines
993 B
Ruby
56 lines
993 B
Ruby
class Plume < ActiveRecord::Base
|
|
belongs_to :image_file
|
|
|
|
belongs_to :data_file
|
|
|
|
belongs_to :couv_image_file, :class_name => "ImageFile"
|
|
|
|
|
|
has_many :plume_cats
|
|
|
|
has_many :plume_articles, :through => :plume_cats
|
|
|
|
has_many :plume_events
|
|
|
|
def v_une_1
|
|
cat = self.plume_cats.where(:title => "édito").first
|
|
if cat
|
|
return cat.plume_articles.first
|
|
|
|
else
|
|
return nil
|
|
end
|
|
|
|
end
|
|
|
|
def v_une_2
|
|
cat = self.plume_cats.where(:title => "Dossier").first
|
|
if cat
|
|
return cat.plume_articles.first
|
|
|
|
else
|
|
return nil
|
|
end
|
|
|
|
end
|
|
|
|
def v_une_3
|
|
cat = self.plume_cats.where(:title => "Grain de sable").first
|
|
if cat
|
|
return cat.plume_articles.first
|
|
|
|
else
|
|
if self.id == 3 and a = self.plume_articles.where(:id => 25).first
|
|
a
|
|
elsif self.id == 11 and a = self.plume_articles.where(:id => 218).first
|
|
a
|
|
else
|
|
return nil
|
|
end
|
|
end
|
|
|
|
end
|
|
|
|
|
|
end
|