Closed btrd closed 4 years ago
Context of the bug
class Place < ApplicationRecord resourcify end class Role < ApplicationRecord PLACE_MANAGER = %w[ coowner_assistant coowner_manager ].freeze end
Then I try to do this :
Place.with_roles(Role::PLACE_MANAGER, current_user) RuntimeError: can't modify frozen Array from /Users/jean/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/rolify-5.2.0/lib/rolify/resource.rb:14:in `map!'
Is it normal that Rolify modify my array that I pass in argument ?
I did this to quickfix the "bug" :
Place.with_roles(Role::PLACE_MANAGER.dup, current_user)
Looks like it is just mutated in place as a convenience:
https://github.com/RolifyCommunity/rolify/blob/e196d70def9ea6e5cbf9e5db00b53a90be768559/lib/rolify/resource.rb#L13-L15
Context of the bug
Then I try to do this :
Is it normal that Rolify modify my array that I pass in argument ?
I did this to quickfix the "bug" :