intridea/multi_json

multi_json 1.6.0 -- undefined method `dump' for ActiveSupport::JSON:Module

Closed this issue · 2 comments

I ran into this today after a bundle update from Rails 3.2.11 to 3.2.12:

ActionView::Template::Error (undefined method `dump' for ActiveSupport::JSON:Module
  (in /home/me/myapp/app/assets/javascripts/application.js.coffee)):
    1: <head>
    2:   <title><%= title %></title>
    3:   <%= stylesheet_link_tag    'application' %>
    4:   <%= javascript_include_tag 'application' %>

Which, of course doesn't make much sense because there's no ruby in the coffee.

I tracked it down to the multi_json gem here:

# Encodes a Ruby object as JSON.
def dump(object, options={})
  options = default_options.merge(options)
  adapter = current_adapter(options)
  adapter.dump(object, options) # <= right there!
end

When in the debugger, the adapter became the ActiveSupport::JSON:Module, which doesn't define a dump method. I don't think this is even the right object for adapter to be holding.

Downgrading from multi_json 1.6.0 to the old 1.5.1 solves the issue.

rwz commented

I couldn't recreate that on a new rails app. Could you please provide backtrace or steps to recreate? Ideally both

Well I have no idea what happened, but the problem seems to have vanished. I tried re-creating it in a new app, then again in my current project, and it worked... : | The only change to my system in between then and now was a reboot. Sorry for taking up your time!