我想執行一個簡單的查詢,但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