本文介绍了轨道/活动记录找到加盟,限制和偏移的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经把下面的查询,它的工作原理我希望它:
I've put together the following query, which works as I expect it to:
stuff = @thing.children.find(
:all,
:joins => :other,
:conditions => {:others => {:another_id => some_id}},
:limit => my_limit,
:offset => my_offset,
)
然而,形式的查询找到(:所有)
是德precated。我试图改变我的查询到以下形式:
However, queries of the form find(:all)
are deprecated. I have tried changing my query to the following form:
stuff = @thing.children.find(
:joins => :other,
:conditions => {:others => {:another_id => some_id}},
:limit => my_limit,
:offset => my_offset,
).all
不过,这将引发一个数据库错误。什么是写这个查询的正确方法?
but this throws a database error. What's the correct way to write this query?
推荐答案
总之,它重写阿雷尔的,你可以简单地说,改变.find来。所有,并删除了:所有的符号,像这样:
Short of rewriting it to Arel, you can simply, change the .find to .all, and remove the :all symbol like so:
stuff = @thing.children.all(
:joins => :other,
:conditions => {:others => {:another_id => some_id}},
:limit => my_limit,
:offset => my_offset,
)
这篇关于轨道/活动记录找到加盟,限制和偏移的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!