mbleigh (owner)

Revisions

gist: 104625 Download_button fork
public
Public Clone URL: git://gist.github.com/104625.git
Embed All Files: show embed
Ruby #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# Let's say we have this:
 
class User < ActiveRecord::Base
  has_many :posts
end
 
class Post < ActiveRecord::Base
  belongs_to :user
end
 
# How do I do these:
 
# 1) Find only users who have at least one post
 
# 2) List users in order of most posts to least posts