Nah, I think you misunderstand. The class method  
self.default_repository_name has to be *immediately* after the include  
DataMapper::Resource. If you put it at the bottom of the class, then  
it throws the error.

Seems like a pretty serious bug. Trying to track down the cause now.  
Hopefully should be able to submit a patch...


On Oct 11, 2009, at 2:33 PM, Brian Smith wrote:

> Well datamapper's normal behavior is to look for a repository  
> named :default, if you use another name you have to tell the  
> resource what name to use :D
>
> On Sun, Oct 11, 2009 at 4:24 PM, Jacques Crocker  
> <[email protected]> wrote:
> Holy shit... that looks like the issue... Why in god's name would  
> that matter!? =)
>
> Thanks for the help Ivan! I never would have figured that out
>
> This seems to work now:
> require "rubygems"
> require "dm-core"
> require "dm-validations"
>
> DataMapper.setup(:mem, :adapter => :in_memory)
> class Employer
>   include DataMapper::Resource
>
>   def self.default_repository_name
>     :mem
>   end
>
>   property :id, Serial
>   property :name, String
>   validates_present :name
> end
>
>
> Employer.new
>
>
> On Oct 11, 2009, at 2:19 PM, Ivan Judson wrote:
>
>>
>> Just a random thought, but move your self.default_repository_name  
>> block to immediately after include DataMapper::Resource.
>>
>> There's a bug I was tracking down related to that, but I can't  
>> remember if it's been fixed.
>>
>> --Ivan
>>
>> Ivan R. Judson
>> Computational Research Scientist
>> 1 Lewis Hall
>> Montana State University
>> (406) 994-7066
>>
>>
>>
>> On Sun, Oct 11, 2009 at 3:17 PM, Jacques Crocker  
>> <[email protected]> wrote:
>> Hi Brian. Do you of any place where this is documented? Or any  
>> sample code?
>>
>> I looked through all the specs in dm-core and the in_memory adapter  
>> still makes absolutely no sense to me.
>>
>> This is what I tried...
>>
>> require "rubygems"
>> require "dm-core"
>> require "dm-validations"
>>
>> DataMapper.setup(:memory, "in_memory://wtf")
>> class Employer
>>   include DataMapper::Resource
>>
>>   property :id, Serial
>>   property :name, String
>>   validates_present :name
>>
>>   def self.default_repository_name
>>     :memory
>>   end
>>
>> end
>>
>> Employer.new
>>
>> this throws the error:
>> DataMapper::IncompleteModelError: Employer must have at least one  
>> property or many to one relationship to be valid
>>
>>
>> When I add Employer.auto_migrate! to the class definition, it  
>> throws this:
>> NoMethodError: undefined method `automigrate!' for Employer:Class
>>
>> Any help greatly appreciated!
>>
>>
>> On Oct 11, 2009, at 2:07 PM, Brian Smith wrote:
>>
>>> I don't think it is, you can just set the repository to be an in  
>>> memory adapter for that model. I think that's the correct way to  
>>> do what you want. It essentially makes it perform like a normal  
>>> class on steroids.
>>>
>>> On Sun, Oct 11, 2009 at 11:49 AM, Ashley Moran 
>>> <[email protected] 
>>> > wrote:
>>>
>>>
>>> On 11 Oct 2009, at 03:06, Brian Smith wrote:
>>>
>>> > isn't there just an in-memory adapter sans sqlite3?
>>>
>>> There is indeed.  Does that mean that the failure to make a new
>>> Resource without its storage existing is not a bug after all?
>>>
>>> --
>>> http://www.patchspace.co.uk/
>>> http://www.linkedin.com/in/ashleymoran
>>> http://aviewfromafar.net/
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>
>>
>>
>>
>>
>>
>
>
>
>
>
> >


--~--~---------~--~----~------------~-------~--~----~
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