Skip to content

Instantly share code, notes, and snippets.

@jilucev
Created August 24, 2018 22:18
Show Gist options
  • Save jilucev/a5e910d2285056ceace7f95c846d1c2b to your computer and use it in GitHub Desktop.
Save jilucev/a5e910d2285056ceace7f95c846d1c2b to your computer and use it in GitHub Desktop.
A rake task
namespace :foo do
desc "Removes all bars for a given foo"\
" Example: bundle exec rake foo:remove_bars[2]"
task :remove_bars, [:foo_id] => [:environment] do |t, args|
foo_id = args[:foo_id].to_i
Bar.where(foo_id: foo_id).delete_all
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment