Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kirillshevch/vandal
ActiveRecord force destroy records with all related associations.
https://github.com/kirillshevch/vandal
activerecord database debugging development rails testing
Last synced: 16 days ago
JSON representation
ActiveRecord force destroy records with all related associations.
- Host: GitHub
- URL: https://github.com/kirillshevch/vandal
- Owner: kirillshevch
- License: mit
- Created: 2018-11-10T15:15:36.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-19T13:10:24.000Z (almost 2 years ago)
- Last Synced: 2024-10-12T10:08:06.668Z (about 1 month ago)
- Topics: activerecord, database, debugging, development, rails, testing
- Language: Ruby
- Homepage:
- Size: 517 KB
- Stars: 7
- Watchers: 3
- Forks: 1
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
[![Gem Version](https://badge.fury.io/rb/vandal.svg)](https://badge.fury.io/rb/vandal)
[![CircleCI](https://circleci.com/gh/kirillshevch/vandal.svg?style=svg)](https://circleci.com/gh/kirillshevch/vandal)
A small gem that helps to *delete an ActiveRecord instance or collection with associations* (skipping callbacks or validations)
## Installation
Add this line to your application's Gemfile and then execute `bundle install`
```ruby
gem 'vandal'
```## Usage
Vandal gem adds 2 methods to `ActiveRecord::Base`
## #vandal_destroy
Delete an ActiveRecord instance with associations even if the callbacks return false or rescue error.
```ruby
class User
has_many :followers # Does not even contain dependent: :destroy
endUser.find_by(id: 1).vandal_destroy
```Followers will deleted along with `User`.
## #vandal_destroy_all
Applies `vandal_destroy` for ActiveRecord collection
```ruby
User.all.vandal_destroy_all
```## Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/kirillshevch/vandal.
## License
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).