class LinkBanner < ActiveRecord::Base
	
	belongs_to :category
	belongs_to :section
	belongs_to :sub_category 

	validates_presence_of :beginning, :ending, :image_url
	validate :validate_beginning_before_ending

   def validate_beginning_before_ending
    if beginning && ending
      errors.add(:ending, "End date must come after beginning date") if ending <= beginning
    end
  end
end
