Sha256: 246254d1ca9049326d502d9dfc080aff3bd3f65d887129942466a05d7a3f74fb

Contents?: true

Size: 1006 Bytes

Versions: 12

Compression:

Stored size: 1006 Bytes

Contents

# frozen_string_literal: true

require 'rails_admin/config/fields'
require 'rails_admin/config/fields/types'
require 'rails_admin/config/fields/types/password'

# Register a custom field factory for devise model
RailsAdmin::Config::Fields.register_factory do |parent, properties, fields|
  if properties.name == :encrypted_password
    extensions = %i[password_salt reset_password_token remember_token]
    fields << RailsAdmin::Config::Fields::Types.load(:password).new(parent, :password, properties)
    fields << RailsAdmin::Config::Fields::Types.load(:password).new(parent, :password_confirmation, properties)
    extensions.each do |ext|
      properties = parent.abstract_model.properties.detect { |p| ext == p.name }
      next unless properties

      field = fields.detect { |f| f.name == ext }
      unless field
        RailsAdmin::Config::Fields.default_factory.call(parent, properties, fields)
        field = fields.last
      end
      field.hide
    end
    true
  else
    false
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
rails_admin-3.2.1 lib/rails_admin/config/fields/factories/devise.rb
rails_admin-3.2.0 lib/rails_admin/config/fields/factories/devise.rb
rails_admin-3.2.0.rc lib/rails_admin/config/fields/factories/devise.rb
rails_admin-3.2.0.beta lib/rails_admin/config/fields/factories/devise.rb
rails_admin-3.1.4 lib/rails_admin/config/fields/factories/devise.rb
rails_admin-3.1.3 lib/rails_admin/config/fields/factories/devise.rb
rails_admin-3.1.2 lib/rails_admin/config/fields/factories/devise.rb
rails_admin-3.1.1 lib/rails_admin/config/fields/factories/devise.rb
rails_admin-3.1.0 lib/rails_admin/config/fields/factories/devise.rb
rails_admin-3.1.0.rc2 lib/rails_admin/config/fields/factories/devise.rb
rails_admin-3.1.0.rc lib/rails_admin/config/fields/factories/devise.rb
rails_admin-3.1.0.beta lib/rails_admin/config/fields/factories/devise.rb