Module: Dsl::ErrorHandling
- Included in:
- ActiveFormObjects::Base
- Defined in:
- lib/dsl/error_handling.rb
Instance Method Summary collapse
Instance Method Details
#map_errors_to(form) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 |
# File 'lib/dsl/error_handling.rb', line 3 def map_errors_to(form) yield rescue ActiveRecord::RecordInvalid, ActiveModel::ValidationError => e record = (e.try(:record) || e.model) = record.errors..as_json record.errors.clear .each do |i| record.errors.add(form, i) end raise ActiveModel::ValidationError, record end |