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