Next week I’ll be attending RailsConf 09 in Las Vegas, NV. Since I’m still pretty new to Rails I’m taking one of the tutorial classes “A-Z Intro to Rails Tutorial” and the presenter has already provided info from his site. Cool!
Next week I’ll be attending RailsConf 09 in Las Vegas, NV. Since I’m still pretty new to Rails I’m taking one of the tutorial classes “A-Z Intro to Rails Tutorial” and the presenter has already provided info from his site. Cool!
Upon continuing a Ruby on Rails project after a few months delay, Aptana Studio’s RadRails editor installed some updates. I suspect something that changed in Rails itself (GEM update) caused the error I received.
undefined method `include_root_in_json=’ for ActiveRecord::Base:Class (NoMethodError)
To fix this error rename the config/initializers/new_rails_defaults.rb to config/initializers/new_rails_defaults.rb.bak.
It appears that the old code placed in these files no longer works with ROR 2.0.2.
# These settings change the behavior of Rails 2 apps and will be defaults
# for Rails 3. You can remove this initializer when Rails 3 is released.# Include Active Record class name as root for JSON serialized output.
ActiveRecord::Base.include_root_in_json = true# Store the full class name (including module namespace) in STI type column.
ActiveRecord::Base.store_full_sti_class = true# Use ISO 8601 format for JSON serialized times and dates.
ActiveSupport.use_standard_json_time_format = true# Don’t escape HTML entities in JSON, leave that for the #json_escape helper.
# if you’re including raw json in an HTML page.
ActiveSupport.escape_html_entities_in_json = false
The file now created in a new project appears as follows:
# These settings change the behavior of Rails 2 apps and will be defaults
# for Rails 3. You can remove this initializer when Rails 3 is released.if defined?(ActiveRecord)
# Include Active Record class name as root for JSON serialized output.
ActiveRecord::Base.include_root_in_json = true# Store the full class name (including module namespace) in STI type column.
ActiveRecord::Base.store_full_sti_class = true
end# Use ISO 8601 format for JSON serialized times and dates.
ActiveSupport.use_standard_json_time_format = true# Don’t escape HTML entities in JSON, leave that for the #json_escape helper.
# if you’re including raw json in an HTML page.
ActiveSupport.escape_html_entities_in_json = false
See http://www.hostingrails.com/1461/dbmigrate-undefined-method-include_root_in_json for more help with this error.