Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

errors.full_messages busted #143

Closed
catmando opened this issue Mar 23, 2019 · 2 comments
Closed

errors.full_messages busted #143

catmando opened this issue Mar 23, 2019 · 2 comments
Labels
bug Something isn't working ready-to-release Internal Use Only: Has been fixed, specs passing and pushed to edge branch
Milestone

Comments

@catmando
Copy link
Contributor

try it and see!

Work around is to apply these two patches:

module ReactiveRecord
  class Base
    def errors
      @errors ||= ActiveModel::Errors.new(ar_instance)
    end
  end
end

module ActiveRecord
  module ClassMethods
     def human_attribute_name(attribute, opts = {})
      opts[:default] || attribute
    end
  end
end
@catmando catmando added the bug Something isn't working label Mar 23, 2019
@catmando catmando added this to the alpha1.5 milestone Mar 23, 2019
@barriehadfield
Copy link
Contributor

@catmando thank you, the patch works perfectly

@barriehadfield
Copy link
Contributor

Additional small bug to be aware of here:

The code below in a failing promise block:

error_messages = []
esult[:models].each do |response_model|
    error_messages.concat response_model.errors.full_messages
    puts "got errors: #{response_model.errors.full_messages}"
end
mutate @error_messages = error_messages

Problem is that the resolved errors will still be returned, so response_model.errors.full_messages does not clear itself of previous errors, so you get:

got errors: First name can't be blank,Last name can't be blank,Last name can't be blank,Last name can't be blank,Last name can't be blank even when first_name is supplied and you have tried a few times.

Expected behaviour is that only the current errors are returned.

@catmando catmando added the ready-to-release Internal Use Only: Has been fixed, specs passing and pushed to edge branch label Apr 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ready-to-release Internal Use Only: Has been fixed, specs passing and pushed to edge branch
Projects
None yet
Development

No branches or pull requests

2 participants