forked from activeadmin/activeadmin
-
Notifications
You must be signed in to change notification settings - Fork 4
Add custom actions and buttons
pupeno edited this page Jan 9, 2012
·
3 revisions
ActiveAdmin.register Post do
# Collection methods
# published_items_admin_post_(path|url)
# /admin/post/published_items
collection_action :published_items do
@collection = Post.published
column(:created_at)
column(:author_name)
column(:published_at)
column(:title) { |resource| resource.truncate(100) }
end
# Member methods
# publish_admin_post_(path|url)
# /admin/post/:id/publish
member_action :publish do
# your normal action code
Post.find(params[:id]).publish!
redirect_to(:back)
end
# Buttons on the top right bar, next to the "New #{model_name}" button.
# show this button only at :published_items action
action_item :only => :published_items do
link_to "button label", action_path(resource)
end
end