No commit activity in last 3 years
No release in over 3 years
Handle silent failure on ActiveRecord models
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.0
>= 0.7.0, ~> 0.7
>= 0.10.0, ~> 0.10
>= 10.3.2, ~> 10.3
~> 2.3
>= 1.3.9, ~> 1.3

Runtime

 Project Readme

SilentFailCheck

Build Status Gem Version Code Climate Test Coverage

This gem aims to track and log silent failure.

Installation

Add this line to your application's Gemfile:

gem 'silent_fail_check'

And then execute:

$ bundle

Or install it yourself as:

$ gem install silent_fail_check

Usage

SilentFailCheck is designed to work with ActiveRecord models. Only ActiveRecord >= 4.0.0 is supported.

Setup

In order to use SilentFailCheck you should have a source table, similar to this:

class CreateSilentFailLog < ActiveRecord::Migration
  def self.up
    create_table :silent_fail_logs do |t|
      t.string :message
      t.timestamps
    end
  end

  def self.down
    drop_table :silent_fail_logs
  end
end

Simple model with validations should look like this:

require 'silent_fail_check'

class SilentFailLog < ActiveRecord::Base
  validates :message, presence: true
end

You can use SilentFailCheck like this:

app/models/user.rb

class User < ActiveRecord::Base
  validates :connection_time, numericality: true

  silent_fail_check :validation, :connection_time
end

In this case, SilentFailCheck will check and log validation errors happened on :connection_time

Configuration

Default configuration method is:

SilentFailCheck::Logger.configure

If your log model has a different schema, you can redefine columns:

SilentFailCheck::Logger.configure(
  model:   SilentFailLog,     # model class name as source
  message: 'MESSAGE_FIELD'    # field that contains name
)

Tests

To run the test suite:

bundle install

Then:

bundle exec rspec

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

Licensing

silent_fail_check is licensed under the MIT License. See LICENSE for full license text.