Suppose I want to add two actions(active and pause) with the show edit delete and show_in_app actions. So how can i accomplish this? I went through https://github.com/sferik/rails_admin/wiki/Actions but i am not able to get the right way..
this is my rails_admin.rb
RailsAdmin.config do |config|
config.actions do
dashboard # mandatory
index # mandatory
new
export
bulk_delete
show
edit
delete
show_in_app
end
end
ANY HELP?????
Custom actions are powerful but a bit tricky. Here is what I did:
rails_admin.rb
require Rails.root.join('lib', 'rails_admin', 'custom_actions.rb')
custom_actions.rb
module RailsAdmin
module Config
module Actions
class Foo
RailsAdmin::Config::Actions.register(self)
register_instance_option :visible? do
# which model
end
register_instance_option :member do
true
end
register_instance_option :link_icon do
'fa fa-star'
end
register_instance_option :controller do
Proc.new do
# put your code here
flash[:notice] = "your message here"
redirect_to show_path
end
end
end
en.yml
en:
admin:
actions:
foo:
menu: 'foo menu'
title: 'foo title'
breadcrumb: 'foo breadcrumb'
I wrote a blog post on it http://dmitrypol.github.io/2015/09/10/rails_admin.html
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.