我在此代碼使用方法「全部」有麻煩:經與「所有」的方法和獲得的煩惱「引發ArgumentError在」
posts = Post.includes(:account).all(:conditions => condition,
:order => "created_at DESC", :limit => postsPerPage,
:offset => (page-1)*postsPerPage)
當我啓動服務器並轉到網頁Padrino拋出一個錯誤:
ArgumentError at/wrong number of arguments (1 for 0)
app/models/post.rb in posts_by_condition
posts = Post.includes(:account).all(:conditions => condition,
:order =>"created_at DESC", :limit => postsPerPage,
:offset => (page-1)*postsPerPage)
app/models/post.rb in publishedPosts
posts_by_condition page, postsPerPage, [""]
app/controllers/main.rb in block (2 levels) in <top (required)>
@posts, @total_pages = Post.publishedPosts(@page, @postsPerPage)
這個問題剛剛出現時,我更新padrino束:
舊版本0.10.3現在是0.12.5,並與其他一些寶石被現實化:
了activerecord 3.1.0 - > 4.2.1
的ActiveSupport 3.1.0 - > 4.2.1
HAML 3.0.25 - > 4.0.6
而且padrino的所有依賴性(芯,幫手,...)
可能這是因爲更新,我試圖使用其他版本的activerecord,它的工作原理,爲什麼不在新版本?
任何幫助將受到歡迎...謝謝
康納的答案是正確的。它突然中斷的原因是'all'方法在active_record中改變了4.現在它的行爲與舊的'scoped'類似,不再立即運行查詢。 – Daiku
這很有用,非常感謝你們兩位。 –