Dup validation 3 2 #6324

Merged
merged 1 commit into from May 15, 2012

Projects

None yet

4 participants

@acapilleri

...for 3-2-stable

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

@acapilleri acapilleri 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
396e383
@rafaelfranca rafaelfranca merged commit 9a868a0 into rails:3-2-stable May 15, 2012
@carlosantoniodasilva
Ruby on Rails member

Great, thanks!

@rafaelfranca
Ruby on Rails member

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

@acapilleri

ok..

@acapilleri

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

@carlosantoniodasilva
Ruby on Rails member

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 acapilleri pushed a commit to acapilleri/rails that referenced this pull request May 15, 2012
Angelo Capilleri add backport for the pull request #6324 e885b18
@rajatvig

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.

@acapilleri

thanks.

@acapilleri

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

That'll work

@acapilleri acapilleri added a commit to acapilleri/rails that referenced this pull request Jun 8, 2012
@acapilleri acapilleri 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
80b8e3f
@acapilleri acapilleri added a commit to acapilleri/rails that referenced this pull request Jun 12, 2012
@acapilleri acapilleri 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
b97e0a1
@carlosantoniodasilva
Ruby on Rails member
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment