Sha256: 981181ff93eb0ebe316089da10accc5bbd9835b54b279d0c3de6973918a76406
Contents?: true
Size: 1.13 KB
Versions: 4
Compression:
Stored size: 1.13 KB
Contents
module ActiveAdminAddons DEFAULT_BOOLEAN_TRUE = '✔' DEFAULT_BOOLEAN_FALSE = '✗' module BoolValues class << self def bool_value(model, attribute) if model[attribute] i18n_lookup(model, attribute, 'true_value', DEFAULT_BOOLEAN_TRUE) else i18n_lookup(model, attribute, 'false_value', DEFAULT_BOOLEAN_FALSE) end end private def i18n_lookup(model, attribute, key, last_default) model_name = model.class.model_name.i18n_key model_i18n = "activeadmin.addons.boolean.models.#{model_name}.#{key}" default_i18n = "activeadmin.addons.boolean.default.#{key}" I18n.t(model_i18n, default: I18n.t(default_i18n, default: last_default)).html_safe end end end module ::ActiveAdmin module Views class TableFor def bool_column(attribute) column(attribute) { |model| BoolValues.bool_value(model, attribute) } end end class AttributesTable def bool_row(attribute) row(attribute) { |model| BoolValues.bool_value(model, attribute) } end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems