Sha256: 9dcc94db1d7728b52b44b5638508fd52492fe6bf68d00038fd83b33cb688e284

Contents?: true

Size: 710 Bytes

Versions: 11

Compression:

Stored size: 710 Bytes

Contents

class Redirect
  include Mongoid::Document
  include Mongoid::Timestamps

  # Mongoid ========================================================================================
  field :source_url
  field :destination_url
  index :source_url, :unique => true
  embedded_in :site, :inverse_of => :redirects

  # Behavior =======================================================================================
  validates_presence_of :destination_url, :source_url
  validates_uniqueness_of :source_url

  # Instance methods ===============================================================================
  def source_url= url
    self[:source_url] = url.gsub /^http:\/\/.+\.#{self.site.try(:domain)}/, ''
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
site_logic-1.9.13 app/models/redirect.rb
site_logic-1.9.12 app/models/redirect.rb
site_logic-1.9.11 app/models/redirect.rb
site_logic-1.9.10 app/models/redirect.rb
site_logic-1.9.9 app/models/redirect.rb
site_logic-1.9.8 app/models/redirect.rb
site_logic-1.9.7 app/models/redirect.rb
site_logic-1.9.6 app/models/redirect.rb
site_logic-1.9.5 app/models/redirect.rb
site_logic-1.9.4 app/models/redirect.rb
site_logic-1.9.3 app/models/redirect.rb