Rameshwar Vyevhare
Rameshwar Vyevhare

Reputation: 2759

Switching my Rails 3.2.12 project to Ruby 2.0.0 fails a test

Switching my Rails 3.2.12 project to Ruby 2.0.0 fails a test:

NoMethodError:
  private method `initialize_dup' called for #<Receipt:0x007fe06c809428>

Looks like initialize_dup is now a private method.

What can I do to get my tests to pass when using Rails 3.2.12 and Ruby 2.0.0?

Upvotes: 4

Views: 1991

Answers (2)

John K. Chow
John K. Chow

Reputation: 1683

For those who are worried about upgrading to 3.2.13 because of some issues it could bring, I added this in an initializer file:

# Because of the Ruby 2.0 privatizes the method and  Rails 3.2.12's use of it
# , and because Rails 3.2.13 (which has a fix) also could potentially
# introduce other bugs, we're adding this patch to fix the issue.
#
# Remove this if the project contains Rails >= 3.2.13
module ActiveModel
  class Errors
    public :initialize_dup
  end

  module Validations
    public :initialize_dup
  end
end

class ActiveRecord::Base
  public :initialize_dup
end

Upvotes: 12

Rameshwar Vyevhare
Rameshwar Vyevhare

Reputation: 2759

It been released please use Ruby 2.0.0 with Rails 3.2.13.rc2 and also fixed the above issue initialize_dup in this released and few more fixes.

http://weblog.rubyonrails.org/2013/3/7/Rails-3-2-13-rc2-has-been-released/

It works for me.

Upvotes: 2

Related Questions