Skip to content

Instantly share code, notes, and snippets.

@lyleunderwood
Created May 17, 2011 23:45
Show Gist options
  • Save lyleunderwood/977679 to your computer and use it in GitHub Desktop.
Save lyleunderwood/977679 to your computer and use it in GitHub Desktop.
class Comment < ActiveRecord::Base
scope :in_public, joins(:post).joins(:category).where("categories.type = 'public'")
belongs_to :post
end
class Post < ActiveRecord::Base
has_many :comments
belongs_to :category
end
class Category < ActiveRecord::Base
has_many :posts
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment