You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Given a User with a collection of unknown roles for a known resource, I would like to remove them all on some condition.
Of course I could do something like
rolify :before_add => :remove_old_roles
def remove_old_roles(role)
roles.where(:resource => role.resource).collect(&:names).each do |old_role_name|
remove_role old_role_name, role.resource
end if do_refresh
end
But what would be superior would be to allow some kind of blank/any syntax such as: current_user.remove_role nil, resource
This currently does not work because the remove_role method casts the param role_name to a string before handing it off to the adapter.
One less-intrusive solution I imagined might be to change the included adapters as such:
I took a crack at doing this myself and would be happy to make a PR, but I can't seem to get the gem to build...? LoadError: cannot load such file -- rolify/adapters/active_record/resource_adapter.rb <_<
Anyways, does this seem like a good change, or is there a better remove_all_roles(resource) solution I am unaware of?
If no one wants to make it, I can, but is there a build procedure or contribution doc I should follow?
The text was updated successfully, but these errors were encountered:
Given a User with a collection of unknown roles for a known resource, I would like to remove them all on some condition.
Of course I could do something like
But what would be superior would be to allow some kind of blank/any syntax such as:
current_user.remove_role nil, resource
This currently does not work because the remove_role method casts the param role_name to a string before handing it off to the adapter.
One less-intrusive solution I imagined might be to change the included adapters as such:
(For reference, I'm thinking in here: https://github.com/RolifyCommunity/rolify/blob/master/lib/rolify/adapters/active_record/role_adapter.rb#L53)
I took a crack at doing this myself and would be happy to make a PR, but I can't seem to get the gem to build...?
LoadError: cannot load such file -- rolify/adapters/active_record/resource_adapter.rb
<_<Anyways, does this seem like a good change, or is there a better remove_all_roles(resource) solution I am unaware of?
If no one wants to make it, I can, but is there a build procedure or contribution doc I should follow?
The text was updated successfully, but these errors were encountered: