Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 506
Rameshwar Vyevhare Avatar asked Dec 09 '22 17:12

Rameshwar Vyevhare


2 Answers

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
like image 176
John K. Chow Avatar answered Dec 11 '22 10:12

John K. Chow


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.

like image 37
Rameshwar Vyevhare Avatar answered Dec 11 '22 10:12

Rameshwar Vyevhare