# encoding: utf-8
class Podujatium < ActiveRecord::Base
  set_primary_key :ID_Podujatie
  set_table_name :podujatia
  
  has_and_belongs_to_many :klienti, :join_table => 'podujatie_klienti', :foreign_key => 'ID_Podujatie', :association_foreign_key => 'ID_Klient'
  has_many :cinnosti, :foreign_key => 'ID_Podujatie', :dependent => :destroy
  has_many :sponzorske_dary, :foreign_key => 'ID_Podujatie', :dependent => :destroy
  has_many :recenzie, :foreign_key => 'ID_Podujatie', :dependent => :destroy
  has_many :galeria_fotky, :foreign_key => 'ID_Podujatie', :dependent => :destroy
  
  belongs_to :c_stav_vstup, :foreign_key => 'ID_Stav_Vstup', :class_name => CStavVstupeniek
  belongs_to :c_stav_podujatia, :foreign_key => 'ID_Stav_Podujatie', :class_name => CStavPodujatium
  
  validates :Nazov, :Miesto, :Datum_Od, :Datum_Do, :ID_Stav_Vstup, :ID_Stav_Pod, :presence => true
  validates_length_of :Nazov, :Popis, :Zhodnotenie, :maximum => 100
  validates_length_of :Miesto, :maximum => 50
end
