Sha256: 03e0d4453439b28864605dc37954dc739000854bd07aa64bb6dc40543d79001e
Contents?: true
Size: 742 Bytes
Versions: 3
Compression:
Stored size: 742 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, Coalla::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.7.0.0 | app/models/lookup.rb |
coalla-cms-0.6.1.1 | app/models/lookup.rb |
coalla-cms-0.6.0.9 | app/models/lookup.rb |