# encoding: utf-8
class GaleriaFotky < ActiveRecord::Base
  set_primary_key :ID_Obrazok
  set_table_name :galeria_fotky
  
  belongs_to :klienti, :foreign_key => 'ID_Klient', :class_name => Klienti
  belongs_to :firmy, :foreign_key => 'ID_Firma', :class_name => Firmy
  belongs_to :podujatia, :foreign_key => 'ID_Podujatie', :class_name => Podujatium
  
  validates :Datum_Vlozenia, :Nazov_Suboru, :presence => true
  validates :Nazov_Suboru, :format => {
      :with => %r{\.(gif|jpg|png)$}i,
      :message => 'Je mozne vlozit adresu URL pre obrazky typu .gif/.jpg/.png'
    }
  
  validates_length_of :Popis, :maximum => 100
  validates_length_of :Nazov_Suboru, :maximum => 40
end
