docs/8-custom-actions.md in activeadmin-0.3.4 vs docs/8-custom-actions.md in activeadmin-0.4.0
- old
+ new
@@ -15,11 +15,11 @@
ActiveAdmin.register Post do
collection_action :import_csv, :method => :post do
# Do some CSV importing work here...
- redirect_to :action => :index, :notice => "CSV imported successfully!"
+ redirect_to {:action => :index}, :notice => "CSV imported successfully!"
end
end
This collection action will generate a route at "/admin/posts/import_csv"
@@ -35,11 +35,11 @@
ActiveAdmin.register User do
member_action :lock, :method => :put do
user = User.find(params[:id])
user.lock!
- redirect_to :action => :show, :notice => "Locked!"
+ redirect_to {:action => :show}, :notice => "Locked!"
end
end
This will generate a route at "/admin/users/:id/lock" pointing to the
@@ -78,9 +78,19 @@
column :id
column :author
column :body do |comment|
simple_format comment.body
end
+ end
+
+### Custom Action Items
+
+To include your own action items (like the New, Edit and Delete buttons), add an
+`action_item` block. For example, to add a "View on site" button to view a blog
+post:
+
+ action_item :only => :show do
+ link_to('View on site', post_path(post)) if post.published?
end
### Page Titles
The page title for the custom action will be the internationalized version of