Project

destroyall

0.0
No commit activity in last 3 years
No release in over 3 years
Simple gem for quick add destroy all method for all models. This gem add simple method destroyall for all models for quick destroy all records in table.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 1.5
>= 0
 Project Readme

Destroyall GEM

Created by Alexandr Basan

TODO: Simple gem for quick add destroy all method for all models.

Attention!!!. This gem delete all records from database without confirmation!!!

Installation

Add this line to your application's Gemfile:

gem 'destroyall'

And then execute:

$ bundle

Or install it yourself as:

$ gem install destroyall

Usage

TODO: Simple gem for quick add destroy all method for all models. This gem add simple method destroyall for all models for quick destroy all records in table. This gem using Ruby method destroy_all:

$ Person.destroy_all("last_login < '2004-04-04'")
$ Person.destroy_all(:status => "inactive")

Gem have 2 methods:

$ destroy_all(model)
$ destroy_all_with_conditions(model, conditions, conditions_value)

Using destroy_all method you can set Model name as argument model. Using destroy_all_with_conditions method you can set Model name as argument model, condition as condition (this argument auto convert to Symbol) and conditional_value as String value for conditions. Example:

$ destroy_all(user)
$ destroy_all_with_conditions(user, status, inactive)

In first method gem destroy all records in table Users In second method gem destroy all records in table Users where user status = inactive

Also you maybe need to create form for delete all records in your model

<%= link_to "Destroy all", data: { confirm: 'Are you sure?' }, :onclick => Destroyall.destroy_all(User) %>

or you can use simple method without gem

<%= link_to "Destroy all", data: { confirm: 'Are you sure?' }, :onclick => User.destroy_all %>

If you need more information about methods using for gem work, please see rubydoc

$ http://apidock.com/rails/ActiveRecord/Base/destroy_all/class

Contributing

  1. Fork it ( http://github.com//destroyall/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request