Skip to content

Commit 813c86b

Browse files
committed
Added docs for :if options on sidebar and action items
1 parent 06eec3d commit 813c86b

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

docs/7-sidebars.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ options.
2525
"Need help? Email us at [email protected]"
2626
end
2727

28+
If you want to conditionally display a sidebar section, use the :if option and
29+
pass it a proc which will be rendered within the context of the view.
30+
31+
sidebar :help, :if => proc{ current_admin_user.super_admin? }
32+
"Only for super admins!"
33+
end
34+
2835
If you only pass a symbol, Active Admin will attempt to locate a partial to render.
2936

3037
# Will render app/views/admin/posts/_help_sidebar.html.erb

docs/8-custom-actions.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,12 @@ post:
9292
link_to('View on site', post_path(post)) if post.published?
9393
end
9494

95+
Actions items also accept the :if option to conditionally display them:
96+
97+
action_item :only => :show, :if => proc{ current_admin_user.super_admin? } do
98+
"Only display this to super admins on the show screen"
99+
end
100+
95101
### Page Titles
96102

97103
The page title for the custom action will be the internationalized version of

0 commit comments

Comments
 (0)