Today I Learned
Ruby’s |= operator: appends values to the array that don’t already exist.
a = [1]
a |= [2] # a == [1, 2]
a |= [2] # a == [1, 2]
via Facundo Espinosa on Twitter
irb accepts an -r option to automatically require gems:
irb -r down
tempfile = Down.download("http://example.com") # look! no require!
Ruby on Rails’ missing fetches records that do not have an associated record. For example A Post that does not have any associated Comments:
Post.where.missing(:comments)