Skip to content

Loading…

breaks when using autosave mode #13

Closed
aserafin opened this Issue · 3 comments

2 participants

@aserafin

Consider this code

class Foo
  has_many :bars, autosave: true
end

bars are validated with special AssociationValidator that will copy errors from bars to the parent Foo object and this breaks HumanMessageFormatter value method.

I don't really care about error messages from Bar in Foo so I've just overriden AssociationValidator class in my project to not put them there.

Another solution would be to rescue nil in this method

  def value
    return if attribute == :base
    base.send :read_attribute_for_validation, attribute rescue nil
  end

in HumanMessageFormatter but it's not the most elegant way.

BTW. awesome library, huge improvement from standard activemodel errors :)

@aq1018
Owner

I'll try reproduce this with a spec first, then I'll see what's the best way to fix this

@aq1018
Owner

This ActiveRecord specific, since ActiveModel seem to handle this differently. I need to dig into ActiveRecord to see how they are integrated.

@aq1018 aq1018 closed this in 1fe1433
@aq1018
Owner

v1.6.6 released

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.