Created
February 23, 2012 19:28
-
-
Save JohnGoodman/1894513 to your computer and use it in GitHub Desktop.
Example custom action
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "rails_admin_duplicate_program/engine" | |
module RailsAdminDuplicateProgram | |
end | |
require 'rails_admin/config/actions' | |
module RailsAdmin | |
module Config | |
module Actions | |
class DuplicateProgram < Base | |
RailsAdmin::Config::Actions.register(self) | |
register_instance_option :member do | |
true | |
end | |
register_instance_option :included do | |
[] | |
end | |
register_instance_option :visible do | |
# Could not get this method working | |
# authorized? and bindings[:abstract_model].in?(included) and not bindings[:abstract_model].in?(excluded) | |
bindings[:object].class.name.downcase == 'program' | |
end | |
# Controller action name | |
# register_instance_option :action_name do | |
# custom_key.to_sym | |
# end | |
# | |
# register_instance_option :visible do | |
# false | |
# end | |
register_instance_option :bulkable? do | |
false | |
end | |
register_instance_option :http_methods do | |
[:get, :post] | |
end | |
register_instance_option :link_icon do | |
'icon-tags' | |
end | |
register_instance_option :controller do | |
# more code here .... | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment