我把以下查询放在一起,它按照我的预期运行:
stuff = @thing.children.find(
:all,
:joins => :other,
:conditions => {:others => {:another_id => some_id}},
:limit => my_limit,
:offset => my_offset,
)
但是,不推荐使用find(:all)
形式的查询。我尝试将查询更改为以下格式:
stuff = @thing.children.find(
:joins => :other,
:conditions => {:others => {:another_id => some_id}},
:limit => my_limit,
:offset => my_offset,
).all
但这会引发数据库错误。编写此查询的正确方法是什么?
答案 0 :(得分:0)
如果没有将其重写为Arel,您可以简单地将.find更改为.all,并删除:all符号,如下所示:
stuff = @thing.children.all(
:joins => :other,
:conditions => {:others => {:another_id => some_id}},
:limit => my_limit,
:offset => my_offset,
)