Created
January 6, 2009 00:27
-
-
Save drogus/43606 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/usr/lib/ruby/gems/1.8/gems/dm-core-0.9.9/lib/dm-core/associations/relationship.rb:106:in `send': undefined method `comments_association' for nil:NilClass (NoMethodError) | |
from /usr/lib/ruby/gems/1.8/gems/dm-core-0.9.9/lib/dm-core/associations/relationship.rb:106:in `get_children' | |
from /usr/lib/ruby/gems/1.8/gems/dm-core-0.9.9/lib/dm-core/associations/relationship.rb:105:in `each' | |
from /usr/lib/ruby/gems/1.8/gems/dm-core-0.9.9/lib/dm-core/associations/relationship.rb:105:in `get_children' | |
from /usr/lib/ruby/gems/1.8/gems/dm-core-0.9.9/lib/dm-core/associations/relationship.rb:172:in `with_repository' | |
from /usr/lib/ruby/gems/1.8/gems/dm-core-0.9.9/lib/dm-core/support/kernel.rb:6:in `repository' | |
from /usr/lib/ruby/gems/1.8/gems/dm-core-0.9.9/lib/dm-core.rb:181:in `repository' | |
from /usr/lib/ruby/gems/1.8/gems/dm-core-0.9.9/lib/dm-core/repository.rb:44:in `scope' | |
from /usr/lib/ruby/gems/1.8/gems/dm-core-0.9.9/lib/dm-core.rb:181:in `repository' | |
from /usr/lib/ruby/gems/1.8/gems/dm-core-0.9.9/lib/dm-core/support/kernel.rb:6:in `repository' | |
from /usr/lib/ruby/gems/1.8/gems/dm-core-0.9.9/lib/dm-core/associations/relationship.rb:172:in `with_repository' | |
from /usr/lib/ruby/gems/1.8/gems/dm-core-0.9.9/lib/dm-core/associations/relationship.rb:80:in `get_children' | |
from /usr/lib/ruby/gems/1.8/gems/dm-core-0.9.9/lib/dm-core/associations/one_to_many.rb:79:in `all' | |
from /usr/lib/ruby/gems/1.8/gems/dm-core-0.9.9/lib/dm-core/associations/one_to_many.rb:17:in `comments' | |
from test.rb:32 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'dm-core' | |
DataMapper.setup(:default, 'sqlite3::memory:') | |
class Article | |
include DataMapper::Resource | |
property :id, Serial | |
property :title, String | |
has n, :comments, :child_key => [:commentable_id], :commentable_class => "Article" | |
end | |
class Comment | |
include DataMapper::Resource | |
property :id, Serial | |
property :text, Text | |
property :commentable_class, String | |
property :commentable_id, String | |
belongs_to :article, :child_key => [:commentable_id], :commentable_class => "Article" | |
end | |
DataMapper.auto_migrate! | |
article = Article.create :title => "Article" | |
article.comments.create(:text => "Comment") | |
puts article.comments(:text => "Comment").inspect |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment