Active Admin: How to set page title?

Consolidating answers and adding a little:

Most of this is on this page on the wiki (or I’ll put it there soon).

Within the file that registers your model for activeadmin (e.g. app/admin/user.rb), you can have

ActiveAdmin.register User do
  # a simple string
  index :title => "Here's a list of users" do
    ...
  end

  # using a method called on the instance of the model
  show :title => :name do
    ...
  end

  # more flexibly using information from the model instance
  show :title => proc {|user| "Details for "+user.name } do
    ...
  end

  # for new, edit, and delete you have to do it differently
  controller do
    def edit
      # use resource.some_method to access information about what you're editing
      @page_title = "Hey, edit this user called "+resource.name
    end
  end
end

Leave a Comment