Rails_admin, the order in which columns in a list are changed

The rails_admin list displays all available model columns according to how the columns are arranged in the database:

pic

However, I need a different order on the list page. I want first nameand then other fields in the table.

Is it possible? The rails_admin documentation does not mention it.

+4
source share
2 answers

Here you can read about ordering fields: https://github.com/sferik/rails_admin/wiki/Fields#inclusion

If your model is called User, create a new configuration file. config/initializers/rails_admin/user.rb

with the following contents:

if User.table_exists?
  RailsAdmin.config User do
    list do
      # simply adding fields by their names (order will be maintained)
      include_fields :name, :id, :created_at, :updated_at, :version, :shopping_malls
    end
  end
end

Let me know if that works out!

+2
source

app/admin/item.rb .

index do column :Name column :id column :created_at end

, id created_at.

0

Source: https://habr.com/ru/post/1617197/


All Articles