Skip to content

Instantly share code, notes, and snippets.

@fernandomm
Created April 24, 2012 02:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fernandomm/2475499 to your computer and use it in GitHub Desktop.
Save fernandomm/2475499 to your computer and use it in GitHub Desktop.
config.actions do
# root actions
dashboard # mandatory
# collection actions
index # mandatory
new
export
bulk_delete
# member actions
show
edit
delete
history_show
show_in_app
collection :publish do
end
end
# in lib/rails_admin_publish.rb
require 'rails_admin/config/actions'
require 'rails_admin/config/actions/base'
module RailsAdminPublish
end
module RailsAdmin
module Config
module Actions
class Publish < RailsAdmin::Config::Actions::Base
register_instance_option :collection do
true
end
register_instance_option :bulkable? do
true
end
register_instance_option :controller do
Proc.new do
@object.update_attribute(:published, true)
flash[:notice] = "You published: #{@object.title}."
redirect_to back_or_index
end
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment