0
如何將limit
添加到此範圍?急於加載限制?
scope :with_comments, include: {comments: :user}
我使用的是這樣的:
Event.with_comments.find(params[:id])
如何將limit
添加到此範圍?急於加載限制?
scope :with_comments, include: {comments: :user}
我使用的是這樣的:
Event.with_comments.find(params[:id])
scope :with_comments, include(comments: :user).limit(5)
default_scope includes(:comments :user).limit(5)
添加到默認範圍
Event.find(params[:id])
這可能嗎? – Zeck
檢查這個問題,你會得到你的答案http://stackoverflow.com/questions/9808674/rails-eager-load-and-limit – SSP