Skip to content

Instantly share code, notes, and snippets.

@tcocca
Forked from dpickett/yo.rb
Created September 25, 2010 18:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tcocca/597112 to your computer and use it in GitHub Desktop.
Save tcocca/597112 to your computer and use it in GitHub Desktop.
def following_by_type(followable_type, options={})
follows = followable_type.constantize.
includes(:followings).
where(
"follows.follower_id = ? AND follows.follower_type = ? AND follows.followable_type = ? AND blocked = ?",
self.id, parent_class_name(self), followable_type, false
)
if options.has_key?(:limit)
return follows.limit(options[:limit])
end
follows
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment