class TaDiscussion < ActiveRecord::Base
  attr_accessible :guest, :guest_picture, :title, :description, :content, :discussion_date, :slots, :place,
                  :url_video, :url_audio, :url_gallery, :ta_discussion_pictures_attributes
  #url_video -> url for news 
  belongs_to :institution
  has_many :ta_discussion_forms, dependent: :destroy
  has_many :ta_discussion_pictures, dependent: :destroy
  accepts_nested_attributes_for :ta_discussion_pictures, allow_destroy: true, reject_if: lambda { |t| t['photo'].nil? }
  
  extend FriendlyId
  friendly_id :title, :use => :slugged

  attr_accessible :guest_picture
  
  has_attached_file :guest_picture, :styles => lambda {|a| { :icon_small=>"x120", :icon_medium=>"x240", :icon_large=>"x360" }}, 
                            :convert_options => { :icon_small => "-quality 75", :icon_medium => "-quality 75", :icon_large => "-quality 75" }, 
                            :processor => :MiniMagick
  validates_attachment_content_type :guest_picture,
                                    :content_type => [ 'image/jpeg', 'image/png', 'image/gif', 'image/jpg', 'image/x-png', 'image/pjpeg' ]

  validates :guest, :title, :description, :discussion_date, presence: true
  
  
end
