active record validation error #13854

Closed
delsoft opened this Issue Jan 27, 2014 · 3 comments

Projects

None yet

2 participants

@delsoft

active record does not save child association when in context

see example in gist: https://gist.github.com/delsoft/8654369

@delsoft

The exact location of the error.
The method is called without passing the validation parameters

#  rails/activerecord/lib/active_record/autosave_association.rb:316
def association_valid?(reflection, record)
    return true if record.destroyed? || record.marked_for_destruction?
    unless valid = record.valid?   # <<<<  ERROR HERE <<<<<<<<  ERROR HERE <<<<<<<<  ERROR HERE <
      if reflection.options[:autosave]
        record.errors.each do |attribute, message|
          attribute = "#{reflection.name}.#{attribute}"
          errors[attribute] << message
          errors[attribute].uniq!
        end
      else
        errors.add(reflection.name)
      end
    end
    valid
  end
@tenderlove tenderlove closed this in #13978 Feb 9, 2014
@tenderlove tenderlove reopened this Feb 20, 2014
@tenderlove
Ruby on Rails member

I had to revert 5e3d466 due to #14106, so I'm reopening this bug since it is not fixed anymore.

@eric-chahin eric-chahin added a commit to eric-chahin/rails that referenced this issue May 1, 2014
@eric-chahin eric-chahin Fixed custom validation context bug where child
associations were not being saved.

Fixes #13854.

Credit to @asn62 (Aaron Nelson) for working together with me on this and
also credit to @Fortisque for the test cases.
41a7a58
@eric-chahin eric-chahin added a commit to eric-chahin/rails that referenced this issue May 1, 2014
@eric-chahin eric-chahin Fixed custom validation context bug where child
associations were not being saved.

Fixes #13854.

[Eric Chahin, Aaron Nelson, & Kevin Casey]
c6d685b
@matthewd matthewd closed this in #14924 May 3, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment