v4 (beta)
Sidebar Sections
Sidebars allow you to put whatever content you want on the side the page.
ruby
sidebar :help do
para "Need help? Email us at help@example.com"
endThis will generate a sidebar on every page for that resource. The first argument is used as the title, and can be a symbol, string, or lambda.
You can also use Arbre to define HTML content.
ruby
sidebar :help do
h3 "Help"
ul do
li "Second List First Item"
li "Second List Second Item"
end
endSidebars can be rendered on a specific action by passing :only or :except.
ruby
sidebar :help, only: :index do
para "Need help? Email us at help@example.com"
endIf you want to conditionally display a sidebar section, use the :if option and pass it a proc which will be rendered within the view context.
ruby
sidebar :help, if: proc{ current_admin_user.super_admin? } do
span "Only for super admins!"
endYou can access your model as resource in the sidebar too:
ruby
sidebar :custom, only: :show do
resource.a_method
endYou can also render a partial:
ruby
sidebar :help # app/views/admin/posts/_help_sidebar.html.erb
sidebar :help, partial: 'custom' # app/views/admin/posts/_custom.html.erbIt's possible to add custom class name to the sidebar parent element by passing class option:
ruby
sidebar :help, class: 'custom_class'By default sidebars are positioned in the same order as they defined, but it's also possible to specify their position manually:
ruby
# will push Help section to the top (above default Filters section)
sidebar :help, priority: 0Default sidebar priority is 10.