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?

-- 
You received this message because you are subscribed to the Google Groups 
"DataMapper" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/datamapper/-/6CBSyCoH_e4J.
To post to this group, send email to datamapper@googlegroups.com.
To unsubscribe from this group, send email to 
datamapper+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/datamapper?hl=en.

Reply via email to