Sha256: 60883973013893e4d4ddf42d9826442e1171ae6e1b0a93bba16989c65b6dcca7

Contents?: true

Size: 631 Bytes

Versions: 2

Compression:

Stored size: 631 Bytes

Contents

# Load field names for custom fields, for Ransack search
if Setting.database_and_table_exists?
  Rails.application.config.after_initialize do
    I18n.backend.load_translations

    translations = {ransack: { attributes: {}}}
    CustomField.find_each do |custom_field|
      if custom_field.field_group.present?
        model_key = custom_field.klass.model_name.singular
        translations[:ransack][:attributes][model_key] ||= {}
        translations[:ransack][:attributes][model_key][custom_field.name] = custom_field.label
      end
    end

    I18n.backend.store_translations(Setting.locale.to_sym, translations)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fat_free_crm-0.13.6 config/initializers/custom_field_ransack_translations.rb
fat_free_crm-0.13.5 config/initializers/custom_field_ransack_translations.rb