2013-07-24 15:43:41 +01:00
|
|
|
class PlatformArchSetting < ActiveRecord::Base
|
|
|
|
DEFAULT_TIME_LIVING = 43200 # seconds, 12 hours
|
|
|
|
MIN_TIME_LIVING = 600 # seconds, 10 minutes
|
2013-07-29 11:59:01 +01:00
|
|
|
MAX_TIME_LIVING = 360000 # seconds, 100 hours, 4 day and 4 hours
|
2014-03-11 08:58:36 +00:00
|
|
|
include TimeLiving
|
2013-07-24 15:43:41 +01:00
|
|
|
|
|
|
|
belongs_to :arch
|
|
|
|
belongs_to :platform
|
|
|
|
|
2014-11-25 16:42:02 +00:00
|
|
|
validates :arch, :platform, presence: true
|
2014-03-11 12:40:44 +00:00
|
|
|
validates :platform_id, uniqueness: { scope: :arch_id }
|
2014-03-12 20:49:36 +00:00
|
|
|
validate lambda {
|
|
|
|
errors.add(:platform, I18n.t('flash.platform_arch_settings.wrong_platform')) unless platform.main?
|
|
|
|
}
|
2013-07-24 15:43:41 +01:00
|
|
|
|
2014-03-11 07:39:25 +00:00
|
|
|
scope :by_arch, ->(arch) { where(arch_id: arch) if arch.present? }
|
|
|
|
scope :by_default, -> { where(default: true) }
|
2013-07-24 15:43:41 +01:00
|
|
|
end
|