Reputation: 11830
Is it possible to use concurrent databases in one rails application? With AR I can use establish_connection method inside a model. Is it possible with datamapper?
Upvotes: 1
Views: 347
Reputation: 7477
There is an analogous feature in Datamapper
. This snippet from this cheatsheet shows how.
DataMapper.setup(:colors_db, "sqlite3:path/to/colors.db")
class Color
include DataMapper::Resource
def self.default_repository_name
:colors_db
end
property :name, String
end
As you can also see there the :repository
argument also changes the source database for many of the DM commands.
Upvotes: 2