# encoding: utf-8
class Firmy < ActiveRecord::Base
  set_primary_key :ID_Firma
  set_table_name :firmy
  
  has_and_belongs_to_many :cinnosti, :join_table => 'cinnosti_firmy', :foreign_key => 'ID_Firma', :association_foreign_key => 'ID_Cinnost'
  has_many :evidencia_zmluv, :foreign_key => 'ID_Firma', :dependent => :destroy
  has_many :sponzorske_dary, :foreign_key => 'ID_Firma', :dependent => :destroy
  has_many :kontaktne_osoby, :foreign_key => 'ID_Firma', :dependent => :destroy
  has_many :galeria_fotky, :foreign_key => 'ID_Firma', :dependent => :destroy
  
  validates :Nazov, :Sidlo, :Stat, :ICO, :Telefon, :Email, :presence => true
  validates_length_of :Nazov, :Sidlo, :Email, :maximum => 50
  validates_length_of :Stat, :maximum => 20
  validates_length_of :ICO, :maximum => 8
  validates_length_of :Telefon, :in => 13..14, :too_short => 'Prosím vložte aj s predvoľbou +421/+420/...'
  validates_length_of :Poznamka, :maximum => 100
end
