Skip to content

Instantly share code, notes, and snippets.

@quinn
Created November 11, 2008 01:43
Show Gist options
  • Save quinn/23711 to your computer and use it in GitHub Desktop.
Save quinn/23711 to your computer and use it in GitHub Desktop.
User < ActiveRecord::Record # thats right
has_many :comments
has_many :bands
def active_comments
comments.find :all do |c|
c.is_active == true
end
end
# ok that was pretty lame and is pretty much
# what ambition does already ( or a named scope ). lets
# see if we can't come up with something a little
# more interesting than that.
def comments_from_my_bands
Comment.select do |c|
bands.include? c.commentable
end
end
# ok it still doesn't feel like its there yet. its not
# blowing my mind yet. how could it blow my mind. . .
def comments_on_me_and_my_bands
Comment.select do |c|
bands.include? c.commentable ||
c.commentable == self
end
end
# huhh its still not totally awesome yet. idk.
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment