Sha256: 712e35af25421d05506149ef571b5b81c6220b8c009225ea88756d778fc3e7cc

Contents?: true

Size: 507 Bytes

Versions: 1

Compression:

Stored size: 507 Bytes

Contents

module Ckpages
  class Page < ActiveRecord::Base
    before_validation :normalize
    validates :path, uniqueness: {case_sensitive: false}
    validates :redirect_url, format: { with: /\A\/|http:\/\/|https:\/\// }, allow_nil: true, allow_blank: true

    def normalize
      self.path = self.path.gsub(/\A\/+/, '')
      self.path = self.path.gsub(/\/+\z/, '')
      self.path = self.path.gsub(/\A\s+/, '')
      self.path = self.path.gsub(/\s+\z/, '')
      self.path = '/' + self.path

    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ckpages-0.1.1 app/models/ckpages/page.rb