0

Content of initializers/rails_defaults.rb

ActiveModel::Base.include_root_in_json = false

The error I get on startup:

NameError: uninitialized constant ActiveModel::Base

Anyone know of a remedy?

I'm using rails 3.1.RC4.

JW8
  • 1,496
  • 5
  • 21
  • 36
sandstrom
  • 14,554
  • 7
  • 65
  • 62

1 Answers1

2

Rails 2.x? Change ActiveModel to ActiveRecord, and look in initializers/new_rails_defaults.rb for the setting.

See:
http://apidock.com/rails/ActiveRecord/Serialization/to_json

Rails 3? Looks like for now you set it in the model directly instead:

class MyModel < ActiveRecord::Base
  self.include_root_in_json = true
end

Edit:
You may also want to look at this:
Rails 3.1 include_root_in_json

Community
  • 1
  • 1
Casper
  • 33,403
  • 4
  • 84
  • 79
  • Thanks! I should've mentioned that I use Rails 3.1. So it is the linked property I'm trying to use. (I think) the problem is that ActiveModel isn't available in the initializer for some reason. – sandstrom Jul 04 '11 at 16:57