i know that active record rails can have multiple connection to be specified in model. we can do something like this right?
class Car < ApplicationRecord
establish_connection("url_to_database")
end
but how to pass the url when initialize the model dynamically? is it possible to do something like this below?
Car.new(url: url)
CodePudding user response:
This should work:
Car.establish_connection(url)
Please note that this database connection is per model not per instance of that model.