Skip to content

Instantly share code, notes, and snippets.

@larsthegeek
Created October 17, 2014 23:25
Show Gist options
  • Save larsthegeek/df254e1ba1f12c9adefd to your computer and use it in GitHub Desktop.
Save larsthegeek/df254e1ba1f12c9adefd to your computer and use it in GitHub Desktop.
# given a model with a postgres array data type called 'wishlist'
# I know I can do
def add_item_to_wishlist(item)
wishlist_will_change!
wishlist = wishlist | item
end
# can I do something like:
def wishlist << (*items)
wishlist_will_change!
write_attribute(:wishlist, wishlist | items)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment