Skip to content

DanielHeath/warnr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Warnr
======

Warnr builds on the power of Rails 3 validations.
It lets you use validations to identify situations which are warnings rather than errors.
It also lets you define a callback on the model which is executed after save if there are any warnings.

Usage Example

class Client < ActiveRecord::Base
  # Notify the client manager that the ABN has not been set
  belongs_to :manager, :class_name => "User"
  
  validates_presence_of :abn, :manager_id
  
  treat_validation_errors_as_warnings_on :abn
  on_save_with_warnings :handle_warnings
  
  def handle_warnings
    MissingDataNotifier.missing_data_notification(client.manager, client).deliver
    # Will save the record in a week, which will trigger this process again.
    DelayedJob.create(1.week, Client, client.id, :save)
  end
end


Copyright (c) 2010 Daniel Heath, released under the MIT license

About

Non-fatal rails 3 validations (ie, warnings rather than errors)

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages