views:

17

answers:

1

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?

+1  A: 

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.

bjg