我想执行一个简单的查询,但Datamapper似乎没有返回正确的结果集。Datamapper没有执行正确的查询
这看起来很基本,没有理由说是错的。
我认为这可能是一个语法问题。
class User
has n, :answers
property :id, Serial
property :name, String
end
class Answer
belongs_to :user
has n, :topics, :through => Resource
property :id, Serial
property :text, Text
end
class Topic
has n, :answers, :through => Resource
property :name, String, :key => true
end
o=User.create(:name=>'tom')
puts a=Answer.create(:user=>o, :text => 'a1', :topics => [
Topic.first_or_create(:name => 'aboutme'),
Topic.first_or_create(:name => '@onetom')
])
#THIS WORKS
#puts Answer.all(:user => {:name => 'tom'}, :topics => [{:name => 'aboutme'}])
#THIS DOES NOT WORK
#puts o.answers.all(:topics => [{:name => 'aboutme'}])
谢谢!问题解决了! = d – 2010-11-22 15:04:08