rule.rb 660 B

12345678910111213141516171819202122232425
  1. # frozen_string_literal: true
  2. # == Schema Information
  3. #
  4. # Table name: rules
  5. #
  6. # id :bigint(8) not null, primary key
  7. # priority :integer default(0), not null
  8. # deleted_at :datetime
  9. # text :text default(""), not null
  10. # created_at :datetime not null
  11. # updated_at :datetime not null
  12. # hint :text default(""), not null
  13. #
  14. class Rule < ApplicationRecord
  15. include Discard::Model
  16. TEXT_SIZE_LIMIT = 300
  17. self.discard_column = :deleted_at
  18. validates :text, presence: true, length: { maximum: TEXT_SIZE_LIMIT }
  19. scope :ordered, -> { kept.order(priority: :asc, id: :asc) }
  20. end