Upgrading from Rails 2 to 3: undefined method use_standard_json_time_format

153 Views Asked by At

I am trying to upgrade Rails from 2.3 to 3.1. I watched the upgrade video from Railscast but I am having some difficulties.

Steps I followed:

  1. Create a separate Rails 3 branch from stable branch.
  2. Update and reload RVM to the latest version.
  3. gem install rails -v 3.0.20.
  4. rails upgrade check and rails upgrade backup using Rails upgrade plugin.
  5. rails new . --skip-active-record

When I start the server I am getting this error:

initializers/new_rails_defaults.rb:13:in `<top (required)>': undefined method `use_standard_json_time_format=' for ActiveSupport:Module (NoMethodError)

Can anyone please help?

1

There are 1 best solutions below

2
Kristján On BEST ANSWER

The default for use_standard_json_time_format changed between Rails 3.0.20 and 3.1.0 from false to true, so depending which version you're aiming for (your question mentions both), you might be able to drop the configuration.

If you're cherry-picking ActiveSupport modules, make sure you've required ActiveSupport::JSON::Encoding, which defines the method.

require 'active_support'
require 'active_support/json/encoding'

And since ActiveSupport.use_standard_json_time_format is just delegating to ActiveSupport::JSON::Encoding, you can also try calling it directly on the latter.

ActiveSupport::JSON::Encoding.use_standard_json_time_format = true