41 lines
		
	
	
		
			984 B
		
	
	
	
		
			Ruby
		
	
	
	
	
	
			
		
		
	
	
			41 lines
		
	
	
		
			984 B
		
	
	
	
		
			Ruby
		
	
	
	
	
	
| # == Schema Information
 | |
| #
 | |
| # Table name: offlines
 | |
| #
 | |
| #  id         :integer          not null, primary key
 | |
| #  end_time   :datetime
 | |
| #  name       :string           not null
 | |
| #  start_time :datetime         not null
 | |
| #  created_at :datetime         not null
 | |
| #  updated_at :datetime         not null
 | |
| #  contest_id :integer          not null
 | |
| #
 | |
| # Indexes
 | |
| #
 | |
| #  index_offlines_on_contest_id  (contest_id)
 | |
| #
 | |
| # Foreign Keys
 | |
| #
 | |
| #  contest_id  (contest_id => contests.id)
 | |
| #
 | |
| class Offline < ApplicationRecord
 | |
|   belongs_to :contest
 | |
| 
 | |
|   has_one_attached :start_image
 | |
|   has_one_attached :end_image
 | |
| 
 | |
|   validates :name, presence: true
 | |
|   validates :start_time, presence: true
 | |
| 
 | |
|   validate :start_image_is_present
 | |
| 
 | |
|   def start_image_is_present
 | |
|     logger = Logger.new(STDOUT)
 | |
|     logger.info "TESTddfzefzef"
 | |
|     logger.info self.start_image.attached?
 | |
|     if !self.start_image.attached?
 | |
|       errors.add(:start_image, I18n.t("activerecord.errors.models.offline.attributes.start_image.blank"))
 | |
|     end
 | |
|   end
 | |
| end
 |