Flowdock

Notes posted by carpeliam

RSS feed
September 9, 2010
1 thank

takes ActiveRecord object as an arg as well

One undocumented feature, you can do this:

person = Person.first
Person.exists?(person)
# => returns true

This came in handy for me when I needed to see if something belonged to a particular scope.

scope = "created_rails"
person = Person.find_by_name "dhh"
Person.send(scope).exists?(person)
# => returns true

Obviously this relies on you having a named_scope in your Person model called “created_rails”.