Module: ValidationErrors::Trackable::InstanceMethods
- Defined in:
- lib/validation_errors.rb
Instance Method Summary collapse
- #save(**options) ⇒ Object
-
#save!(**options) ⇒ Object
Attempts to save the record just like ActiveRecord::Base#save but will raise an ActiveRecord::RecordInvalid exception instead of returning
false
if the record is not valid. - #update(attributes) ⇒ Object
- #update!(attributes) ⇒ Object
Instance Method Details
#save(**options) ⇒ Object
38 39 40 41 42 |
# File 'lib/validation_errors.rb', line 38 def save(**) super.tap do |result| ValidationError.track(self) unless result || persisted? end end |
#save!(**options) ⇒ Object
Attempts to save the record just like ActiveRecord::Base#save but will raise an ActiveRecord::RecordInvalid exception instead of returning false
if the record is not valid.
46 47 48 49 50 51 |
# File 'lib/validation_errors.rb', line 46 def save!(**) super rescue ActiveRecord::RecordInvalid ValidationError.track(self) unless persisted? raise end |
#update(attributes) ⇒ Object
25 26 27 28 29 |
# File 'lib/validation_errors.rb', line 25 def update(attributes) super.tap do |result| ValidationError.track(self) unless result end end |
#update!(attributes) ⇒ Object
31 32 33 34 35 36 |
# File 'lib/validation_errors.rb', line 31 def update!(attributes) super rescue ActiveRecord::RecordInvalid ValidationError.track(self) raise end |