Skip to content

Instantly share code, notes, and snippets.

@philcrissman
Created October 12, 2011 17:11
Show Gist options
  • Save philcrissman/1281853 to your computer and use it in GitHub Desktop.
Save philcrissman/1281853 to your computer and use it in GitHub Desktop.
destroy_all, with conditions.
> # on a model, works fine.
> Voucher.destroy_all(:user_id => nil)
=> # works as expected; returns an array of the records it destroyed, and said records have been deleted.
> # on a collection:
> wv.voucher_restrictions.destroy_all(:restriction_id => 108)
=> ArgumentError: wrong number of arguments (1 for 0)
> # but... this works:
> wv.voucher_restrictions.where(:restriction_id => 108).destroy_all
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment