Skip to content

Commit

Permalink
Establish a connection for PostgreSQL.
Browse files Browse the repository at this point in the history
  • Loading branch information
dblock authored Dec 30, 2020
1 parent a163cd7 commit 99e91ed
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ gem 'slack-ruby-bot-server'

#### ActiveRecord

Use ActiveRecord with, for example, PostgreSQL via [pg](https://github.com/ged/ruby-pg). Configure the database connection in `postgresql.yml`. Add the `activerecord`, `pg`, `otr-activerecord` and `cursor_pagination` gems to your Gemfile.
Use ActiveRecord with, for example, PostgreSQL via [pg](https://github.com/ged/ruby-pg). Add the `activerecord`, `pg`, `otr-activerecord` and `cursor_pagination` gems to your Gemfile.

```
gem 'pg'
Expand All @@ -73,6 +73,40 @@ gem 'otr-activerecord'
gem 'cursor_pagination'
```

Configure the database connection in `config/postgresql.yml`.

```yaml
default: &default
adapter: postgresql
pool: 10
timeout: 5000
encoding: unicode

development:
<<: *default
database: bot_development

test:
<<: *default
database: bot_test

production:
<<: *default
database: bot
```
Establish a connection in your startup code.
```ruby
ActiveRecord::Base.establish_connection(
YAML.safe_load(
ERB.new(
File.read('config/postgresql.yml')
).result, [], [], true
)[ENV['RACK_ENV']]
)
```

### OAuth Version and Scopes

Configure your app's [OAuth version](https://api.slack.com/authentication/oauth-v2) and [scopes](https://api.slack.com/legacy/oauth-scopes) as needed by your application.
Expand Down

0 comments on commit 99e91ed

Please sign in to comment.