I'm trying to do something relatively simple with a m2m association,
but I'm getting an error and I don't know what to make of it. This is
my first DB so please bear with me (new to ruby as well). I come from
a Core Data background…

Anyway, the pasted code is here: http://pastie.org/1063216 but I'll
paste it in the message too:

#Syncable
require 'model/client.rb'

class Syncable
        include DataMapper::Resource

        property :id, Serial
        property :entityName, String
        property :uniqueIdentifier, String
        property :timestamp, String

        has n, :clients, :through => Resource

end


#Client
require 'model/syncable.rb'

class Client
        include DataMapper::Resource

        property :id, Serial
        property :clientIdentifier, String


        has n, :syncables, :through => Resource

end


# Where I'm using it
require 'model/syncable.rb'
require 'model/client.rb'
require 'model/syncableSub.rb'

DataMapper.setup(:default, "sqlite://#{Dir.pwd}/data.sqlite3")
DataMapper.finalize
DataMapper.auto_upgrade!
        syncSub = SyncableSubclass.first_or_create(:uniqueIdentifier =>
changeAttributes["uniqueIdentifier"])

        # the join name will be ClientSyncable

        syncSub.clients << Client.new(:clientIdentifier =>
h["clientIdentifier"]) #causing error as seen below...
        syncSub.save

# the error:
NoMethodError - undefined method `lazy_load' for nil:NilClass:


So I'm using a subclass of my "Syncable" class and I can set all the
attributes of the sub+super class just fine on the instance (I've
edited that part out for the post). But as soon as I try to access or
set syncSub.clients I get that error followed by a trace pointing to
that line.

I'm thinking this should be something very simple but as I am new to
this, it doesn't make complete sense to me.

I'm using DM 1.0 and all my gems are updated, using Snow Leopard if
any of those details matter.

Thanks in advance!

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