Render a custom page in ActiveAdmin using Rails 3

activeadmin, ruby-on-rails-3

Solution

Sample page, rendering /app/views/admin/password/_index.html.haml partial:

ActiveAdmin.register_page "Password" do

  menu label: I18n.t("menu.change_password")

  content do
    render "index"
  end

end

Default url for this page is /admin/password (you can check it by calling 'rake routes'). If your page title contains spaces, you have to use aa version from github, because it was impossible until this commit - https://github.com/gregbell/active_admin/commit/30b19c86eef3c504fe71c2e39e072620169b80c2

Problem

I have seen the following page: http://activeadmin.info/docs/9-custom-pages.html It doesn´t have a lot of information on how to create a custom page. What I need to do is to add a custom action to the index of an entity that redirects me to another page i.e. /admin/mycustompage . I want to render my new page from a partial. It has to look similar to a view or edit page (with a breadcrumb and the layout). The example in the docs is too simple: ``` ActiveAdmin.register_page "My Page" do content do para "Hello World" end end ``` How can I render a partial within the content? How can I render the breadcrumb? How is the url for this new page specified? Thanks.

Original source