Skip to content
This repository was archived by the owner on Jun 17, 2025. It is now read-only.

mattdenner/activerecord-warnings

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ActiveRecord Warnings

This gem adds support for warnings to ActiveRecord::Base instances. Warnings do not fail the record being saved but should be presented to the user. The warnings work through the standard validation mechanism.

To add warnings to your model:

class MyModel < ActiveRecord::Base
  warnings do
    validates_presence_of :name
  end
end

x = MyModel.create!
x.warnings? # => true
x.warnings.on(:name) # => "can't be blank"

Any validation calls within the warnings block will be classed as a warning. The warnings method returns an ActiveRecord::Errors instance, just as the default errors implementation does.

About

Adds warnings to ActiveRecord so that validations can be used

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages