I am using datamapper in association with postgres
I have 2 classes defined like this:
class Dep
include DataMapper::Resource
property :id, Serial
has 1, :rec, 'Rec'
end
class Rec
include DataMapper::Resource
property :id, Serial
belongs_to :dep, 'Dep'
end
When I try to do so and access the dep model I get an error: undefined method 'rec_id' for #
As far as my research goes the model that is created does not have a one to one relationship. Instead it has a one to many relationship. I think that is the problem. Is there any way to create a one to one relationship in datamapper?
Further, it does not let me use :required => false with 'has 1'
Using belongs_to both side does not create a proper relationship. It creates to relationships instead which is undesirable. Can anyone help me with this issue?