Created
January 6, 2009 14:19
-
-
Save drogus/43833 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.8/lib/dm-core/adapters/data_objects_adapter.rb:79:in `execute_reader': ambiguous column name: articles.id (Sqlite3Error) | |
Query: SELECT "articles"."id", "articles"."name" FROM "articles" INNER JOIN "articles" ON "articles"."id" = "comments"."commentable_id" WHERE "articles"."id" = '3' AND "comments"."commentable_class" = 'Article' ORDER BY "articles"."id" LIMIT 1 from /usr/lib/ruby/gems/1.8/gems/dm-core-0.9.8/lib/dm-core/adapters/data_objects_adapter.rb:79:in `read_one' | |
from /usr/lib/ruby/gems/1.8/gems/dm-core-0.9.8/lib/dm-core/adapters/data_objects_adapter.rb:202:in `with_connection' | |
from /usr/lib/ruby/gems/1.8/gems/dm-core-0.9.8/lib/dm-core/adapters/data_objects_adapter.rb:74:in `read_one' | |
from /usr/lib/ruby/gems/1.8/gems/dm-core-0.9.8/lib/dm-core/repository.rb:131:in `read_one' | |
from /usr/lib/ruby/gems/1.8/gems/dm-core-0.9.8/lib/dm-core/model.rb:339:in `first' | |
from /usr/lib/ruby/gems/1.8/gems/dm-core-0.9.8/lib/dm-core/associations/many_to_one.rb:45:in `article_helper' | |
from /usr/lib/ruby/gems/1.8/gems/dm-core-0.9.8/lib/dm-core/associations/many_to_one.rb:70:in `article' | |
from lib/tester.rb:56 |
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], Comment.commentable_class => "Article" | |
end | |
DataMapper.auto_migrate! | |
article = Article.create :title => "Article" | |
comment = article.comments.create(:text => "Comment") | |
puts comment.article.inspect |
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" | |
comment = article.comments.create(:text => "Comment") | |
puts comment.article.inspect |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment