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.
educoder/app/models/ec_score_level.rb

12 lines
322 B

6 years ago
class EcScoreLevel < ApplicationRecord
belongs_to :ec_course
default_scope { order(position: :asc) }
def compare_condition
max_position = self.class.maximum(:position)
# 特殊情况:只有一条记录
position < max_position || max_position == 1 ? 'not_less_than' : 'less_than'
end
end