ruby-on-railsrails-activerecordoctopus

Rails using multiple databases - no implicit conversion of nil into String


I am trying to setup connection to another DB

class Something < ApplicationRecord
  self.abstract_class = true
  establish_connection {adapter:"postgresql",host:"localhost",port:5432,database:"dev_x",user:"user",password:"1234"}
end

But whenever I try to run a method on (e.g.: Something.all) it I receive error:

no implicit conversion of nil into String

Any idea why?


Solution

  • Worth mentioning why I didn't use code properly. We are also using Octopus gem (gem for running multiple database). Native establish_connection method doesn't seem to work when Octopus is turned on :(.

    For all of you out there - use octopus_establish_connection but beware: https://github.com/thiagopradi/octopus/issues/101