You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi! I'm using mongoid alongside postgresql in a rails 5 app.
My resque jobs work perfectly with the mongoid models, however, whenever I try to use one of my postgresql tables inside a job, I get the following error:
PG::UndefinedTable: ERROR: relation "admins" does not exist LINE 1: SELECT "admins".* FROM "admins" ^ : SELECT "admins".* FROM "admins"
This is my lib/tasks/resque.rake file
require 'resque/tasks'
task "resque:setup" => :environment do
ENV['QUEUE'] = '*'
Resque.before_fork do
defined?(ActiveRecord::Base) and
ActiveRecord::Base.connection.disconnect!
end
Resque.after_fork do
defined?(ActiveRecord::Base) and
ActiveRecord::Base.establish_connection
end
end
The postgres table mentioned does exist, and works perfectly with the rails app. It seems like, at least outside of the main rails app, ActiveRecord defaults to using mongoid, so none of my postgresql models are visible inside the worker.
Am I missing something?
The text was updated successfully, but these errors were encountered:
Hi! I'm using mongoid alongside postgresql in a rails 5 app.
My resque jobs work perfectly with the mongoid models, however, whenever I try to use one of my postgresql tables inside a job, I get the following error:
This is my lib/tasks/resque.rake file
The postgres table mentioned does exist, and works perfectly with the rails app. It seems like, at least outside of the main rails app, ActiveRecord defaults to using mongoid, so none of my postgresql models are visible inside the worker.
Am I missing something?
The text was updated successfully, but these errors were encountered: