Skip to content

Commit

Permalink
Add include_errors!
Browse files Browse the repository at this point in the history
  • Loading branch information
antulik committed Jun 29, 2024
1 parent fc564a6 commit 4c136c6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/active_interaction/extras.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@ def initialize_with(&block)
end
end

concern :IncludeErrors do
include ActiveInteraction::Extras::Halt

def include_errors!(model, **mapping)
errors.merge! model.errors, **mapping
halt_if_errors!
end
end
end
end

Expand Down
1 change: 1 addition & 0 deletions lib/active_interaction/extras/all.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ module ActiveInteraction::Extras::All
include ActiveInteraction::Extras::FormFor
include ActiveInteraction::Extras::AfterInitialize
include ActiveInteraction::Extras::InitializeWith
include ActiveInteraction::Extras::IncludeErrors

end

0 comments on commit 4c136c6

Please sign in to comment.