Sha256: cce2254e5ffbf273b9d5fdb9a6ac704a672f0f1b6fc84b4648ef37ba09ea55d3
Contents?: true
Size: 741 Bytes
Versions: 12
Compression:
Stored size: 741 Bytes
Contents
module Guts # Option model class Option < ActiveRecord::Base include TrackableConcern include MultisiteScopeConcern # Regex for replacing key values with KEY_REGEX = /[^a-zA-Z0-9_ ]/i validates :key, presence: true, length: { minimum: 3 } belongs_to :site has_many :tracks, as: :object trackable :create, :update, :destroy, fields: [:value] # Setter override for setting key def key=(key) self[:key] = key.gsub(KEY_REGEX, '').gsub(/\s+/, '_').downcase.chomp end # Simple helper lookup for keys # @param [Symbol] key the option key to look up # @return [Object] the option record def self.for_key(key) find_by_key key end end end
Version data entries
12 entries across 12 versions & 1 rubygems