11# Custom Pages
22
3- Although it's nice to be able to register resources, sometimes you need a non
4- resourceful page in your application. Active Admin supports the generation of
5- custom pages using the same familiar syntax available for resources.
3+ When you need a standalone page on your site, Custom Pages will be there with a familiar syntax to resource registration.
4+
5+ ## Available Features
6+ * main page content
7+ * menu item
8+ * sidebars
9+ * action_items
10+ * page_actions
611
712## Create a new Page
813
@@ -15,31 +20,17 @@ Creating a page is a simple as calling the `register_page` method:
1520 end
1621
1722In the above example, a new page will be created at ` /admin/my_page ` with the
18- title "My Page" and the content of "Hello World". Anything rendered within the
19- ` # content` block will be set in the main content area of the page.
23+ title "My Page" and the content of "Hello World". Anything rendered within
24+ ` content ` will be the main content on the page.
2025
2126## Page Title & I18n
2227
2328Coming soon...
2429
2530## Customize the Menu
2631
27- The menu item is available to customize just like in any other resource in
28- Active Admin:
29-
30- ActiveAdmin.register_page "My Page" do
31- menu :label => "My Menu Item Label", :parent => "Dashboard"
32-
33- content do
34- para "Hello World"
35- end
36- end
37-
38- This configuration will add the page to the menu with the label "My Menu Item
39- Label" and will nest it underneath the "Dashboard" link.
40-
41- To view the full list of available menu options visit ([ Resource
42- Customization] ( 2-resource-customization.md ) )
32+ The menu item is available to customize just like
33+ [ any other resource] ( 2-resource-customization.md#customize-the-menu ) in Active Admin.
4334
4435## Add a Sidebar Section
4536
@@ -59,11 +50,8 @@ in Active Admin:
5950 end
6051 end
6152
62- This configuration creates a sidebar section named "Help" with an unordered list
63- in it.
64-
65- To view the full list of available sidebar section options visit
66- ([ Sidebars] ( 7-sidebars.md ) )
53+ This creates a sidebar section named "Help" containing an unordered list.
54+ To view the full customization options, visit [ Sidebars] ( 7-sidebars.md ) .
6755
6856## Add an Action Item
6957
@@ -80,5 +68,29 @@ Just like other resources, you can add Action Item's to pages:
8068 end
8169 end
8270
83- This configuration adds an action item that links to the root URL of the
84- application.
71+ This adds an action item that links to the root URL of the application.
72+
73+ ## Add a Page Action
74+
75+ ` page_action ` allows you to define controller actions specific to this page,
76+ and is the functional equivalent of ` collection_action ` .
77+
78+ ActiveAdmin.register_page "My Page" do
79+
80+ page_action :ex, :method => :post do
81+ # do stuff here
82+ redirect_to admin_my_page_path, :notice => "You did stuff!"
83+ end
84+
85+ action_item do
86+ link_to "Do Stuff", admin_my_page_ex_path, :method => :post
87+ end
88+
89+ content do
90+ para "Hello World"
91+ end
92+ end
93+
94+ This defines the route ` /admin/my_page/ex ` which can handle HTTP POST requests.
95+
96+ Clicking on the ` action_item ` will reload page with the message "You did stuff!"
0 commit comments