Sha256: 111dfc557f711324150cdea168d511168ca06136951637c2b9c64bb13c2f53d0

Contents?: true

Size: 965 Bytes

Versions: 2

Compression:

Stored size: 965 Bytes

Contents

# frozen_string_literal: true

class SunriseUser < Sunrise::AbstractModel
  self.resource_name = 'User'

  index :table do
    field :email
    field :updated_at
    field :id

    group :search do
      field :email
      field :name
    end
  end

  index :thumbs do
    scope { User.includes(:avatar) }
    preview ->(user) { user.avatar.try(:url, :thumb) }

    field :email, label: false
    field :updated_at, label: false
    field :id

    group :search do
      field :email
      field :name
    end
  end

  export do
    field :id
    field :name
    field :email
  end

  form do
    permited_attributes lambda { |user|
      user.admin? ? :all : [:name, :password, :password_confirmation, :avatar_attributes]
    }

    field :name
    field :email
    field :password
    field :password_confirmation
    field :role_type_id, collection: -> { RoleType.all }

    group :bottom, holder: :bottom do
      field :avatar, as: :uploader
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sunrise-cms-1.1.1 lib/generators/sunrise/templates/models/sunrise/sunrise_user.rb
sunrise-cms-1.1.0 lib/generators/sunrise/templates/models/sunrise/sunrise_user.rb