2012-05-23 37 views
0

我已經把下面的查詢,因爲我期待它其中工程:軌道/活動記錄找到加盟,限制和抵消

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

我覺得你應該使用AREL,u能easiely consruct相同詢問 –

回答

1

總之,它重寫阿雷爾的,你可以簡單地說,改變.find來。所有,並刪除了:所有的符號,像這樣:

stuff = @thing.children.all(
    :joins => :other, 
    :conditions => {:others => {:another_id => some_id}}, 
    :limit => my_limit, 
    :offset => my_offset, 
)