ruby on rails - Create two navigation link for single table in rails_admin gem -
i have 1 table named user.
in have 2 type of record :
1) corporation
2) agency
field name is_agency?(boolean). if agency true , if corporation false.
i want display user table 2 different table corporation , agency in admin side. used rails_admin gem.
how can differentiate using "is_agency?" field ?
i check rails_admin gem documentation did't find thing this.
please me find out solution, save hours.
you can crate custom action described here: https://github.com/sferik/rails_admin/wiki/custom-action
for example
# in lib/rails_admin/agency.rb require 'rails_admin/config/actions' require 'rails_admin/config/actions/base' module railsadmin module config module actions class agency < railsadmin::config::actions::base railsadmin::config::actions.register(self) register_instance_option :controller proc.new @objects = project.where(is_agency: true) render "index" end end register_instance_option :collection true end register_instance_option :link_icon 'icon-th-list' end end end end end
then have add rails_admin.rb initializer
config.actions dashboard # mandatory index agency ['user'] end
then same corporation.
do not forget add translations locales rails_admin.en.yml
another way using scopes: https://github.com/sferik/rails_admin/wiki/list search scopes in text.
hope helps, best regards, ioannis
Comments
Post a Comment