Skip to content

A custom RailsAdmin action to display objects in a grid.

License

Notifications You must be signed in to change notification settings

zenpow/rails_admin_grid

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RailsAdminGrid

Gem Version

RailsAdminGrid is a custom collection action for RailsAdmin that displays objects in a grid with thumbnails. It provides an alternative to the default list view provided in RailsAdmin.

Preview

alt tag

Installation

Add the following to your Gemfile before rails_admin:

gem 'rails_admin_grid'

Configuration

Global

You must add the custom action to the list of actions in your global RailsAdmin configuration. The default, with RailsAdminGrid added, looks like this:

# config/initializers/rails_admin.rb
RailsAdmin.config do |config|
  config.actions do
    # root actions
    dashboard                     # mandatory
    # collection actions 
    index                         # mandatory
    new
    export
    history_index
    bulk_delete
    # member actions
    show
    edit
    delete
    history_show
    show_in_app

    grid                          # RailsAdminGrid
  end
end

Since RailsAdminGrid works best for displaying models with an associated picture, it may not be desirable to use on every model. You can restrict the models for which the action is available using the steps described here.

Model

To configure RailsAdminGrid's behavior on a specific model, you must include a grid block in your model configuration, as such:

rails_admin do
  grid do
    thumbnail_method do
      :thumb
    end
  end
end

The only information RailsAdmin requires to function properly is a thumbnail_method, a method which it will use to retrieve the corresponding thumbnail for the object. Visible fields and copes can also be configured in this block.

These properties must be specified in the list block instead of the grid block:

  • items_per_page
  • sort_reverse
  • sort_by

About

A custom RailsAdmin action to display objects in a grid.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • HTML 62.6%
  • Ruby 37.4%