-
-
Save atomical/5722743 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
class RolesController < ApplicationController | |
include Hydra::RoleManagement::RolesBehavior | |
prepend_before_filter :accept_batches, only: [:destroy] | |
def destroy | |
@roles.each {|role| role.destroy} | |
redirect_to roles_path, notice: "Successfully deleted groups: #{params[:ids].join(", ")}" | |
end | |
def accept_batches | |
if params[:id] | |
params[:ids] = [params[:id]].flatten | |
params[:id] = nil | |
end | |
params[:ids] ||= [] | |
#This implementation of batch works based upon cancan's returning of all roles when no params[:id] is supplied | |
#Thus authorize_resource is checking can? :delete, Role instead of can? :delete, 1, can? :delete, 2, etc. | |
#Or is cancan able to check @roles instead?!? | |
@roles = Role.where(id: params[:ids]) | |
end | |
end |
This file contains hidden or 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
resources :roles do | |
collection do | |
delete :destroy | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment