Rails3 + Datamapper - concurrent database connections
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 d开发者_如何转开发atamapper?
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.
精彩评论