Sha256: b15051e6030076bcb9171380746407c996b4081ea67ce5ae76b8cd8e0a8e4f8d

Contents?: true

Size: 924 Bytes

Versions: 8

Compression:

Stored size: 924 Bytes

Contents

# 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

8 entries across 8 versions & 1 rubygems

Version Path
fat_free_crm-0.15.2 config/initializers/custom_field_ransack_translations.rb
fat_free_crm-0.16.4 config/initializers/custom_field_ransack_translations.rb
fat_free_crm-0.15.1 config/initializers/custom_field_ransack_translations.rb
fat_free_crm-0.16.3 config/initializers/custom_field_ransack_translations.rb
fat_free_crm-0.16.2 config/initializers/custom_field_ransack_translations.rb
fat_free_crm-0.16.1 config/initializers/custom_field_ransack_translations.rb
fat_free_crm-0.16.0 config/initializers/custom_field_ransack_translations.rb
fat_free_crm-0.15.0 config/initializers/custom_field_ransack_translations.rb