
belongs_to associations not working for me
Reported by Jim | December 5th, 2007 @ 05:46 PM
#!/usr/bin/env ruby
require 'rubygems'
require 'data_mapper'
# add setup code here
User.auto_migrate!
Comment.auto_migrate!
class User < DataMapper::Base
property :name, :string
has_many :comments, :class => 'Comment', :foreign_key => 'user_id'
end
class Comment < DataMapper::Base
property :comment, :text, :lazy => false
belongs_to :author, :class => 'User', :foreign_key => 'user_id'
end
u1 = User.create(:name => "u1")
p u1.comments
Comment.create(:comment => "c", :author => u1)
p u1.comments #=> should not be []
u1.reload!
p u1.comments #=> or at least, this should not be []
Comments and changes to this ticket
-
Sam Smoot December 28th, 2007 @ 12:07 AM
- Assigned user set to Sam Smoot
- State changed from new to open
This is specced in r641, and it's my very next priority... promise. :-)
-
Sam Smoot December 30th, 2007 @ 09:04 PM
- Milestone cleared.
-
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »