gitlab-org--gitlab-foss/app/models/redirect_route.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

21 lines
555 B
Ruby
Raw Permalink Normal View History

# frozen_string_literal: true
class RedirectRoute < ApplicationRecord
include CaseSensitivity
belongs_to :source, polymorphic: true # rubocop:disable Cop/PolymorphicAssociations
validates :source, presence: true
validates :path,
length: { within: 1..255 },
presence: true,
uniqueness: { case_sensitive: false }
2017-05-03 17:14:30 +00:00
2017-08-08 00:16:38 +00:00
scope :matching_path_and_descendants, -> (path) do
wheres = 'LOWER(redirect_routes.path) = LOWER(?) OR LOWER(redirect_routes.path) LIKE LOWER(?)'
2017-08-08 00:16:38 +00:00
where(wheres, path, "#{sanitize_sql_like(path)}/%")
end
end