Skip to main content

Group Actions

Group related custom actions under a single dropdown, either by wrapping them in action_group or by giving them the same group_name.

Quick example​

cm_show page_title: :title do
action_group "Status", icon_name: "fa-regular fa-flag" do
custom_action name: "approve", route_type: "member", verb: "patch", path: ":id/approve", display_type: :button do
::Post.find(params[:id]).tap(&:approved!)
end
custom_action name: "reject", route_type: "member", verb: "patch", path: ":id/reject", display_type: :button do
::Post.find(params[:id]).tap(&:rejected!)
end
end
end

Options​

action_group(name, icon_name: "fa fa-list", icon_style: nil, &block)
NameTypeDefaultDescription
nameStringrequiredLabel of the dropdown.
icon_nameString"fa fa-list"Font Awesome icon of the group.
icon_styleStringnilInline style for the group icon.

Every custom_action declared inside the block joins the group and takes its icon.

Recipes​

Group without a block​

Actions with the same group_name are grouped together, even when declared apart:

custom_action name: "approve", group_name: "Status", route_type: "member", verb: "patch",
path: ":id/approve", display_type: :button do
::Post.find(params[:id]).tap(&:approved!)
end