rule.rb 569 B

12345678910111213141516171819202122
  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. #
  13. class Rule < ApplicationRecord
  14. include Discard::Model
  15. self.discard_column = :deleted_at
  16. validates :text, presence: true, length: { maximum: 300 }
  17. scope :ordered, -> { kept.order(priority: :asc, id: :asc) }
  18. end