I have a feeling this relates to the identity map solution in Rails, where all 
calls are wrapped inside a DataMapper.repository(:default) { ... } block.  From 
DataMapper's perspective, you're inside such a block, and therefore it doesn't 
check default_repository_name.  Is it possible to completely override 
#repository to return the one you want?

The problem, if this is the case, is that you lose the benefits of the IM, when 
working with multiple repositories.

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 at 
> http://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.

Reply via email to