28 lines
841 B
Ruby
28 lines
841 B
Ruby
class Campaign < ActiveRecord::Base
|
|
has_many :videolistings, :dependent => :delete_all
|
|
accepts_nested_attributes_for :videolistings,:reject_if => :all_blank, :allow_destroy => true
|
|
validates :listingcode, presence: true, uniqueness: true
|
|
validates :advertisername, presence: true
|
|
validates :websiteurl, presence: true
|
|
validates :description, presence: true
|
|
validates :productsandservices, presence: true
|
|
after_save :send_to_better_video
|
|
validate :has_at_least_one_videolisting
|
|
after_initialize :set_defaults
|
|
def set_defaults
|
|
self.clientid = 720
|
|
end
|
|
def has_at_least_one_videolisting
|
|
errors.add(:base, 'Must add at least one Videolisting') if self.videolistings.blank?
|
|
end
|
|
|
|
|
|
|
|
def send_to_better_video
|
|
if self.processed_changed? && self.processed == true
|
|
#TODO Make API Calls
|
|
end
|
|
end
|
|
|
|
end
|