BigW Consortium Gitlab

redirect_route.rb 440 Bytes
Newer Older
1
class RedirectRoute < ActiveRecord::Base
2
  belongs_to :source, polymorphic: true # rubocop:disable Cop/PolymorphicAssociations
3 4 5 6 7 8 9

  validates :source, presence: true

  validates :path,
    length: { within: 1..255 },
    presence: true,
    uniqueness: { case_sensitive: false }
10 11

  scope :matching_path_and_descendants, -> (path) { where('redirect_routes.path = ? OR redirect_routes.path LIKE ?', path, "#{sanitize_sql_like(path)}/%") }
12
end