开发者

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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜