Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions lib/queue_classic/conn.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@ def connection
@connection ||= connect
end

def connection=(connection)
unless connection.instance_of? PG::Connection
raise(
ArgumentError,
"connection must be an instance of PG::Connection, but was #{connection.class}"
)
end
@connection = connection
end

def disconnect
connection.finish
ensure
Expand Down
10 changes: 8 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,14 @@ require "queue_classic/tasks"
**config/initializers/queue_classic.rb**

```ruby
# Optional if you have this set in your shell environment or use Heroku.
ENV["DATABASE_URL"] = "postgres://username:password@localhost/database_name"
# queue_classic will by default look for an environment variable DATABASE_URL
# or QC_DATABASE_URL for a connection string in the format
# "postgres://username:password@localhost/database_name". If you use Heroku,
# this will already be set.
#
# If you don't want to set this variable, you can set the connection in an
# initializer.
QC::Conn.connection = ActiveRecord::Base.connection.raw_connection
```

queue_classic requires a database table and a PL/pgSQL function to be loaded
Expand Down