Skip to content

Instantly share code, notes, and snippets.

@stevenharman
Created August 30, 2011 02:15
Show Gist options
  • Save stevenharman/1179987 to your computer and use it in GitHub Desktop.
Save stevenharman/1179987 to your computer and use it in GitHub Desktop.
Thing.first.discussions.started_by(User.first)
class Discussion < ActiveRecord::Base
belongs_to :thing
scope :started_by lambda { |user| where(:initiated_by_id => user) }
end
class Thing < ActiveRecord::Base
belongs_to :user
has_many :discussions
end
class User < ActiveRecord::Base
has_many :things
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment