You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
792 B
22 lines
792 B
class CompetitionStaff < ActiveRecord::Base
|
|
default_scope order: 'position asc'
|
|
|
|
attr_accessible :minimum, :maximum, :category, :position
|
|
|
|
belongs_to :competition
|
|
|
|
validates :position, numericality: { only_integer: true }
|
|
validates :minimum, numericality: { only_integer: true, greater_than: 0 }
|
|
validates :maximum, numericality: { only_integer: true, greater_than_or_equal_to: lambda { |obj| obj.minimum } }
|
|
validates :category, presence: true, inclusion: { in: %w(all teacher student profession) }
|
|
|
|
def category_text
|
|
I18n.t("competition_staff.category.#{category}", locale: 'zh')
|
|
end
|
|
|
|
def self.category_options
|
|
%w(all teacher student profession).map do |category|
|
|
[I18n.t("competition_staff.category.#{category}", locale: 'zh'), category]
|
|
end
|
|
end
|
|
end |