Sha256: 7a8c5c1162405526f424e1d28c0434468ee9d9273176882696775ab7fe1ae725

Contents?: true

Size: 955 Bytes

Versions: 11

Compression:

Stored size: 955 Bytes

Contents

# frozen_string_literal: true

# Copyright (c) 2008-2013 Michael Dvorkin and contributors.
#
# Fat Free CRM is freely distributable under the terms of MIT license.
# See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php
#------------------------------------------------------------------------------
# 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

11 entries across 11 versions & 1 rubygems

Version Path
fat_free_crm-0.21.0 config/initializers/custom_field_ransack_translations.rb
fat_free_crm-0.20.1 config/initializers/custom_field_ransack_translations.rb
fat_free_crm-0.20.0 config/initializers/custom_field_ransack_translations.rb
fat_free_crm-0.19.2 config/initializers/custom_field_ransack_translations.rb
fat_free_crm-0.19.0 config/initializers/custom_field_ransack_translations.rb
fat_free_crm-0.18.2 config/initializers/custom_field_ransack_translations.rb
fat_free_crm-0.17.3 config/initializers/custom_field_ransack_translations.rb
fat_free_crm-0.18.1 config/initializers/custom_field_ransack_translations.rb
fat_free_crm-0.18.0 config/initializers/custom_field_ransack_translations.rb
fat_free_crm-0.17.2 config/initializers/custom_field_ransack_translations.rb
fat_free_crm-0.17.1 config/initializers/custom_field_ransack_translations.rb