當試圖在Rails 3.0.7中使用find_by_sql時,我有一個很奇怪的問題。 Rails不會返回任何東西(空結果,[]),但如果我複製&將完全相同的查詢粘貼到mysql中,它將返回結果。find_by_sql Ruby on Rails 3沒有結果
這就是我想用Rails:
Document.find_by_sql(["select d.* from documents d, categorizations cg, combinations co where d.id = cg.document_id and co.id = cg.combination_id and co.assigned_parent_category_id=?", 1)
回報:[]
,這就是我在MySQL做:
select documents.*
from documents, categorizations, combinations
where documents.id = categorizations.document_id
and combinations.id = categorizations.combination_id
and combinations.assigned_parent_category_id=1
回報:1分的結果
難道這是一個Rails錯誤還是我做錯了什麼?謝謝 !