5
6
7
8
9
10
11
12
13
|
# File 'lib/cancan/unauthorized_message_resolver.rb', line 5
def unauthorized_message(action, subject)
subject = subject.values.last if subject.is_a?(Hash)
keys = unauthorized_message_keys(action, subject)
variables = {}
variables[:action] = I18n.translate("actions.#{action}", default: action.to_s)
variables[:subject] = translate_subject(subject)
message = I18n.translate(keys.shift, **variables.merge(scope: :unauthorized, default: keys + ['']))
message.blank? ? nil : message
end
|