PASTEBIN
| #1 paste tool since 2002
create new paste
tools
api
archive
faq
PASTEBIN
create new paste
trending pastes
sign up
login
my alerts
my settings
my profile
Don't like ads?
PRO users
don't see any ads ;-)
Public Pastes
Untitled
3 sec ago
Untitled
6 sec ago
Untitled
8 sec ago
Untitled
14 sec ago
Untitled
16 sec ago
Untitled
22 sec ago
123124
C++ | 18 sec ago
ser_1371677107681
30 sec ago
Untitled
By: a guest on
Jun 26th, 2012
| syntax:
None
| size: 0.22 KB | hits: 10 | expires: Never
download
|
raw
|
embed
|
report abuse
|
print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
Rails: List of categories where related items count is greater than 0
@categories = Category.where(category.items.count > 0).all
Category.joins(:items).select('distinct categories.*')
Items.find(:all).categories.uniq
create a
new version
of this paste
RAW Paste Data
Rails: List of categories where related items count is greater than 0 @categories = Category.where(category.items.count > 0).all Category.joins(:items).select('distinct categories.*') Items.find(:all).categories.uniq