Sha256: 786d4e27878b90ef4798ba749af27ab7f0e1aae953c8c5f1a974d0af6a2f33aa
Contents?: true
Size: 1.01 KB
Versions: 1
Compression:
Stored size: 1.01 KB
Contents
require 'rails_admin/config/fields/types/enum' module RailsAdmin module Config module Fields module Types class ActiveRecordEnum < Enum RailsAdmin::Config::Fields::Types.register(self) def type :enum end register_instance_option :enum do abstract_model.model.defined_enums[name.to_s] end register_instance_option :pretty_value do bindings[:object].send(name).presence || ' - ' end register_instance_option :multiple? do false end register_instance_option :queryable do false end def parse_value(value) value.present? ? enum.invert[value.to_i] : nil end def parse_input(params) params[name] = parse_value(params[name]) if params[name] end def form_value ::Rails.version >= '5' ? enum[super] : super end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rails_admin-1.0.0.rc | lib/rails_admin/config/fields/types/active_record_enum.rb |