yes, the method I was talking about was in model. now you are using no IdentiyMaps for the external repo and you can add it by adding "use Rails::..." in the ApplicationController. but make sure the order is correct or use these #repository trick for ALL models.
- Kristian On Jun 30, 3:56 pm, Bence <[email protected]> wrote: > Thanks! > > I overrode the #repository as you described, and it seems to have done > the trick. I did this in the model - I guess this is what you meant by > "binding in a static way"? > > Where do the "use 'Rails::...'" lines go? Are they required? I'm not > using them right now at all, and the repository seems to be the right > one on my external model. > > //B > > On Jun 29, 6:56 am, kristian <[email protected]> wrote: > > > > > > > > > what I do on almost all my projects (datamapper makes it to easy to > > use morethen one repo) is that I am using nested IdentityMaps one for > > the default and one for the :external repository > > > use 'Rails::DataMapper::IdentityMaps', :external > > use 'Rails::DataMapper::IdentityMaps' > > > in order to "dispatch" the models onto the right repository I am > > overwrite this method > > > def self.repository(name = nil, &block) > > super(:external, &block) > > end > > > so basically I bind the model to the :external repository in static > > way. the same thing I do for transactions ! > > > maybe that helps. > > > - Kristian > > > On Jun 29, 6:41 am, Chris Corbyn <[email protected]> wrote: > > > > Note that you can disable that "everything is wrapped in a repository > > > block" behaviour by removing this line from ApplicationController: > > > > use Rails::DataMapper::Middleware::IdentityMap > > > > You won't have an identity-map per-request if you do this though. > > > > On 28/06/2011, at 21:48, Bence wrote: > > > > > Hi, > > > > > I'm new to DataMapper and run into a confusing issue to which I didn't > > > > find any answers. > > > > > I have two repositories (:default and :external). > > > > Model "ext_model" is persisted in :external by setting the > > > > default_repository_name in the model. The model works: the unit tests > > > > are green and I can manipulate the model in the console without > > > > problems. > > > > When I run the unit tests on controller ext_model_controller#index, it > > > > is green: retrieves all from ext_model, as it should. > > > > But when I launch the webserver and browse to /ext_model_controller/ > > > > index, I get an error message, and I see that it is looking for > > > > ext_model in the :default repository (instead of :external). > > > > Shouldn't both the console and the server retrieve the model the same > > > > way? Am I missing something? How do I set explicitly the repository on > > > > the model so that the webserver uses that? > > > > If I wrap the code inside ext_model_controller#index action in > > > > DataMapper.repository(:external) {...} then it works, but shouldn't > > > > this be unnecessary since I already explicitly assigned a repository > > > > to the model? > > > > > Thanks in advance! > > > > > //Bence > > > > > Rails 3.0.9, dm 1.1.0 > > > > > -- > > > > You received this message because you are subscribed to the Google > > > > Groups "DataMapper" group. > > > > To post to this group, send email to [email protected]. > > > > To unsubscribe from this group, send email to > > > > [email protected]. > > > > For more options, visit this group > > > > athttp://groups.google.com/group/datamapper?hl=en. -- You received this message because you are subscribed to the Google Groups "DataMapper" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/datamapper?hl=en.
