Skip to content

Commit 7233511

Browse files
authored
Update README Postgres example for Ruby 3.1 (#170)
* Update README Postgres example for Ruby 3.1 * Update command to load config * Take YAML loading from tests
1 parent bf1e46a commit 7233511

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,13 @@ production:
101101
Establish a connection in your startup code.
102102
103103
```ruby
104-
ActiveRecord::Base.establish_connection(
105-
YAML.safe_load(
106-
ERB.new(
107-
File.read('config/postgresql.yml')
108-
).result, [], [], true
109-
)[ENV['RACK_ENV']]
110-
)
104+
yml = ERB.new(File.read(File.expand_path('config/postgresql.yml', __dir__))).result
105+
db_config = if Gem::Version.new(Psych::VERSION) >= Gem::Version.new('3.1.0.pre1')
106+
::YAML.safe_load(yml, aliases: true)[ENV['RACK_ENV']]
107+
else
108+
::YAML.safe_load(yml, [], [], true)[ENV['RACK_ENV']]
109+
end
110+
ActiveRecord::Base.establish_connection(db_config)
111111
```
112112

113113
### OAuth Version and Scopes

0 commit comments

Comments
 (0)