开发者

Rails3 + Datamapper - concurrent database connections

开发者 https://www.devze.com 2023-01-10 11:12 出处:网络
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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消