Rails Admin Custom title for table for scope

77 views Asked by At

I am using Rails Admin.

And I and Showing two scopes under user section. I want to show table header with the record count in it like "Active (100)" and "Disabled (10)"

  config.model "User" do
   list do
    scopes %i[active disabled]
    field :id
    field :first_name
    field :last_name
    field :address_line1
    field :address_line2
    field :city
  end
end

enter image description here Please suggest some solution how can I add record count in table title.

1

There are 1 answers

0
Guillermo Siliceo Trueba On

You will need to override the rails_admin template that renders the list. Specifically this file: https://github.com/railsadminteam/rails_admin/blob/master/app/views/rails_admin/main/index.html.erb

You'll need to add it to your project so rails_admin choose it to render over the built-in one.

that would be app/views/rails_admin/main/index.html.erb

And then look at line 89 of that file, that's the line you need to modify to get custom naming.