Dup validation 3 2 #6324

Merged
merged 1 commit into from May 15, 2012

Conversation

Projects
None yet
4 participants
Contributor

acapilleri commented May 15, 2012

...for 3-2-stable

It Fixes #5953 the 3-2-stable, it's the same pull request of #6284

clean the errors if an object that includes validations errors is dup…
…ed,for 3-2-stable

It Fixes #5953 in 3-2-stable, it's the same pull request of #6284
Contributor

acapilleri commented May 15, 2012

rafaelfranca added a commit that referenced this pull request May 15, 2012

@rafaelfranca rafaelfranca merged commit 9a868a0 into rails:3-2-stable May 15, 2012

Great, thanks!

Owner

rafaelfranca commented May 15, 2012

@acapilleri This pull request broke the build for Ruby 1.8.7. Please investigate it. http://travis-ci.org/#!/rails/rails/jobs/1337434

Contributor

acapilleri commented May 15, 2012

ok..

Contributor

acapilleri commented May 15, 2012

@rafaelfranca, I tested this on my local machine and it goes well

It can't, initialize_dup does not exist on Ruby 1.8. See this for a backport example from AMo::Errors: https://github.com/rails/rails/pull/4492/files.

acapilleri pushed a commit to acapilleri/rails that referenced this pull request May 15, 2012

rajatvig commented Jun 8, 2012

The backport fix has broken code on our end when using ActiveModel::Validations inside a Hashie::Dash.

Scenario

class A < Hashie::Dash
  property :a, :default => "b"
end

A.new.to_s
#<A a="b">
A.new.dup.keys
["a"]

class B < Hashie::Dash
  include ActiveModel::Validations
  property :a, :default => "b"
end

B.new.to_s
#<B>
B.new.dup.keys
[]

The fix is to call super at the end of initialized_dup.
We are using Ruby 1.9.3p194. The hashie gem is 1.x.

Contributor

acapilleri commented Jun 8, 2012

thanks.

Contributor

acapilleri commented Jun 8, 2012

yes but this fix not works with 1.8.x , it works with 1.8.x and 1.9.x with something like that :

 def initialize_dup(other) # :nodoc:
      @errors = nil
      super if respond_to?(:super)
 end

cc / @carlosantoniodasilva

rajatvig commented Jun 8, 2012

That'll work

acapilleri added a commit to acapilleri/rails that referenced this pull request Jun 8, 2012

Fix the the backport of the object dup with the ruby 1.9.3p194.
At the end of initialize_dup was added the call to super if it existsi,
so it also works with 1.8.7 where initialize_dup doesn't exist.
It was introduced with the pull request #6324

acapilleri added a commit to acapilleri/rails that referenced this pull request Jun 12, 2012

Fix the the backport of the object dup with the ruby 1.9.3p194.
At the end of initialize_dup was added the call to super if it exists,
so it also works with 1.8.7 where initialize_dup doesn't exist.
This issu was introduced with the pull request #6324
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment