Sha256: ecc129cff6c8ff55d9934df06fa7b7e07115b5025f2bdb9bbd2532811c72525e
Contents?: true
Size: 734 Bytes
Versions: 3
Compression:
Stored size: 734 Bytes
Contents
class Lookup < ActiveRecord::Base validates_presence_of :code validates_uniqueness_of :code validates_numericality_of :value, only_integer: true, if: ->(lookup) { lookup.type_code == 'integer' } validates_numericality_of :value, if: ->(lookup) { lookup.type_code == 'float' } mount_uploader :file, FileUploader def value_options attr_value = read_attribute(:value_options) if attr_value.present? ActiveSupport::JSON.decode(attr_value).with_indifferent_access else {} end end def value_options=(value) write_attribute(:value_options, ActiveSupport::JSON.encode(value).to_s) if value.present? end def select_options value_options.map { |key, value| [value, key] } end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
coalla-cms-0.5.2.4 | app/models/lookup.rb |
coalla-cms-0.5.1.9 | app/models/lookup.rb |
coalla-cms-0.5.1.8 | app/models/lookup.rb |