mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-01 02:03:22 +00:00
Patch CanCan deprecated keyword arguments
Solves an issue with use of deprecated positional args. The version of CanCan which fixes this is not currently compatible with OFN...
This commit is contained in:
12
config/initializers/cancancan.rb
Normal file
12
config/initializers/cancancan.rb
Normal file
@@ -0,0 +1,12 @@
|
||||
module CanCanUnauthorizedMessage
|
||||
# Fix deprecated syntax calling I18n#translate (using keyword args) without using **
|
||||
def unauthorized_message(action, subject)
|
||||
keys = unauthorized_message_keys(action, subject)
|
||||
variables = {:action => action.to_s}
|
||||
variables[:subject] = (subject.class == Class ? subject : subject.class).to_s.underscore.humanize.downcase
|
||||
message = I18n.translate(nil, **variables.merge(:scope => :unauthorized, :default => keys + [""]))
|
||||
message.blank? ? nil : message
|
||||
end
|
||||
end
|
||||
|
||||
CanCan::Ability.prepend(CanCanUnauthorizedMessage)
|
||||
Reference in New Issue
Block a user