Gives users the ability to customize which columns are visible in their interface, making data views more flexible, and sorting by multiple columns.

Description

ActiveScaffold Config List allows users to dynamically select which columns are displayed in ActiveScaffold tables, offering a flexible way to customize data views. Version 4.0 also supports controller-defined, user-saved, and global named views.

Installation

Add the following line to your Gemfile:

gem 'active_scaffold_config_list'

Then run:

bundle install

Usage & Options

Enable column selection in your controller:

class UsersController < ApplicationController
  active_scaffold :user do |config|
    config.actions << :config_list
  end
end

Example Code

config.config_list.columns = [:name, :email, :role, :last_login] # available columns
config.config_list.default_columns = [:name, :email]

Named Views

Define reusable list views with their own columns in the controller:

config.config_list.add_view :simple, [:name, :email]

Named views can also have a custom label, sorting, and authorization method. When database persistence is enabled, users can save their dynamic configuration under a name, return to it later, and optionally share it as a global view.

Saving Configurations for Users

Version 4.0 adds the has_config_lists model helper. After creating a ListConfiguration model with the required storage columns, use the helper to create the user association and the methods that load configurations and list saved views:

class User < ApplicationRecord
  has_config_lists "ListConfiguration",
    association_options: {dependent: :delete_all}
end

Configure the controller to use those methods:

config.config_list.save_to_user = :config_list_for
config.config_list.named_views_method = :config_list_views

save_to_user enables database persistence for the user’s current list configuration. named_views_method also lets the user save configurations by name and switch between them.

Read the named views tutorial for the complete version 4.0 setup.

Get Plugin