0
在我的Rails應用程序,我做了一系列搜索組對象的很多,像Rails:將索引幫助範圍搜索?
scope :best_of_the_week, ->(time) do
start_time = time.beginning_of_week
end_time = time.end_of_week
where("created_at > ? AND created_at < ?", start_time, end_time).where('votes_count > ?', 300).order('votes_count DESC').first(8)
end
在這種情況下,我需要索引添加到created_at
?怎麼樣votes_count?
另外,我怎麼能優雅地結合前兩個搜索?或者將它們結合起來有什麼區別?
有'between'和''<' '>什麼區別?我應該選擇哪一個? – cqcn1991
我曾經搜過,找不到解釋,通常我之間用,因爲更具可讀性,直到現在我沒有任何問題。 –