Inspired by activeadmin_addons and its Enum Integration I want to make similar functionality for AASM by letting users change events depending on their abilities and available events/statuses in model.
Sorry i have no time to create an addon right now for this gem but i will try to do it soon. Feel free to modify, use it and integrate. Ask me any question if you need!
Gem: ActiveAdmin, Gem 'active_admin_role', both are installed and working AdminUser model with current_admin_user setup (or similar to your app).
Tested with Rails 5.1.3.
After you finish and deploy/run server you must "Reload" Permissions in admin and enable "event_update
" for manager or other than "super_admin" roles.
(in addition to below attached files)
In your AdminUser model add:
include CanCan::Ability
include ActiveAdminRole::CanCan::Ability
In your table_for (is where you render columns of data)
column 'Our Status' do |auction|
render 'admin/auctions/event_change', auction: auction
end
In initializers/active_admin.rb or whenever you want
ActiveAdmin::ResourceController.class_eval do
protected
def current_ability
# Match to your current admin user
@current_ability ||= Ability.new(current_admin_user)
end
end
also make sure your config:
config.authorization_adapter = ActiveAdmin::CanCanAdapter
config.authorization_adapter = ActiveAdmin::CanCanAdapter
config.cancan_ability_class = 'Ability'
Pardon me if I forgot something, let me know if you have any question or problem !!