AaronLasseigne / active_interaction

:briefcase: Manage application specific business logic.
MIT License
2.06k stars 136 forks source link

Something strange with full_messages method for errors #556

Closed TruesSpeak closed 1 year ago

TruesSpeak commented 1 year ago

Hello @AaronLasseigne ! Recently, the rails project at my work updated the gem and encountered strange behavior. The full_messages method outputs an empty array for errors. At the same time, messages displays correct information for errors. I patched the ActiveInteraction class with my hands::Errors, added image And everything started working, but what surprised me was that in the tests in the gem repository, the method works without problems so. I attach screenshots image We up version of gem from (3.8.3) to (5.2.0) because up ruby and rails versions to 3.2.1 and 7.0.4.2 Maybe you have any ideas how to fix it?

AaronLasseigne commented 1 year ago

It seems to be working for me on 5.2.0.

class I < ActiveInteraction::Base
  string :s

  def execute
    s
  end
end

I.run.errors.full_messages
=> ["S is required"]
class I < ActiveInteraction::Base
  string :s

  validates :s, length: { minimum: 2 }

  def execute
    s
  end
end

I.run(s: 'a').errors.full_messages
=> ["S is too short (minimum is 2 characters)"]
AaronLasseigne commented 1 year ago

Can you provide an example interaction where it fails?