Skip to content

Commit

Permalink
Compatibility with older and newer versions of psych gem
Browse files Browse the repository at this point in the history
  • Loading branch information
elohanlon committed Jan 10, 2024
1 parent e5651dd commit d0cbdf3
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/models/concerns/cul/omniauth/abilities.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ def config
@role_proxy_config ||= begin
root = (Rails.root.blank?) ? '.' : Rails.root
path = File.join(root,'config','roles.yml')
_opts = YAML.load_file(path)
# We'll use YAML loading logic similar to Rails 7, for older and newer psych gem compatibility
# https://github.com/rails/rails/blob/7-1-stable/activesupport/lib/active_support/encrypted_configuration.rb#L99
_opts = YAML.respond_to?(:unsafe_load) ? YAML.unsafe_load(config) : YAML.load(config)
all_config = _opts.fetch("_all_environments", {})
env_config = _opts.fetch(Rails.env, {})
symbolize_hash_keys(all_config.merge(env_config))
Expand Down

0 comments on commit d0cbdf3

Please sign in to comment.