2017-05-01 20:46:30 +00:00
|
|
|
class RedirectRoute < ActiveRecord::Base
|
2017-06-02 12:29:30 +00:00
|
|
|
belongs_to :source, polymorphic: true # rubocop:disable Cop/PolymorphicAssociations
|
2017-05-01 20:46:30 +00:00
|
|
|
|
|
|
|
validates :source, presence: true
|
|
|
|
|
|
|
|
validates :path,
|
|
|
|
length: { within: 1..255 },
|
|
|
|
presence: true,
|
|
|
|
uniqueness: { case_sensitive: false }
|
2017-05-03 17:14:30 +00:00
|
|
|
|
|
|
|
scope :matching_path_and_descendants, -> (path) { where('redirect_routes.path = ? OR redirect_routes.path LIKE ?', path, "#{sanitize_sql_like(path)}/%") }
|
2017-05-01 20:46:30 +00:00
|
|
|
end
|