Git Product home page Git Product logo

broken_record's Introduction

BrokenRecord

Build status

Provides a rake task for scanning your ActiveRecord models and detecting validation errors.

Installation

Add this line to your application's Gemfile:

gem 'broken_record'

And then execute:

bundle

Or install it yourself as:

gem install broken_record

Usage

To scan all records of all models in your project:

rake broken_record:scan

If you want to scan all records of a specific model (e.g. the User model):

rake broken_record:scan[User]

You can also specify a list of models to scan:

rake broken_record:scan[Product,User]

Configuration

BrokenRecord provides a configure method with multiple options. Here's an example:

BrokenRecord.configure do |config|
    # Skip the Foo and Bar models when scanning.
    config.classes_to_skip = [Foo, Bar]

    # Set a scope for which models should be validated
    config.default_scopes = { Foo => proc { with_bars } }

    # The follow block will be called before scanning your records.
    # This is useful for skipping validations you want to ignore.
    config.before_scan do
        User.skip_callback :validate, :before, :user_must_be_active
    end

    # BrokenRecord uses the parallelize gem to distribute work across
    # multiple cores. The following block will be called every time
    # the process is forked (useful for re-establishing connections).
    config.after_fork do
      Rails.cache.reconnect if Rails.cache.respond_to? :reconnect
    end

    # The compact_output option will report the ids of invalid records
    # but it will omit any relevant messages or backtraces.
    config.compact_output = true
end

Contributing

  1. Fork it
  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

broken_record's People

Contributors

nikhilmat avatar nickgervasi avatar jaredsmithse avatar swhopkins avatar alexevanczuk avatar bss avatar kbackowski avatar gchavan avatar karlotcha avatar alexgerstein avatar danielh257 avatar brendar avatar kryptonat avatar mprastzp avatar ansonlc avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.