开发者

Setting properties on ActiveModel::Base from an initializer

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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜