On The Mark

  • About

    aside 6 Mar

    ROR Error: undefined method `include_root_in_json=’ …

    Background

    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.

    Error Message

    undefined method `include_root_in_json=’ for ActiveRecord::Base:Class (NoMethodError)

    Solution

    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

    Footnotes

    See  http://www.hostingrails.com/1461/dbmigrate-undefined-method-include_root_in_json for more help with this error.


    [Translate]
  • Recent Posts

    • Code generation for property ‘Image’ failed
    • Removing Dell Backup and Recovery
    • Apple mobile device service failed to start
    • How To: SQL Server Reporting Date Formating
    • Unable to find Adobe PDF resource file. “Acrobat PDFMaker” “You must have administrator privileges to install these files. Please contact your local system administrator.
    • .NET Framework execution was aborted by escalation policy because of out of memory.
    • SQL Query: Determine view or stored procedures using tables, columns, functions, etc
    • iPhone OS4 Update for 3G
    • Because of a protocol error detected at the client (code 0×1104), this session will be disconnected. Please try connecting to the remote computer again.
    • Application Essentials Installer
  • Recent Comments

    • TG on Apple mobile device service failed to start
    • Sam on Because of a protocol error detected at the client (code 0×1104), this session will be disconnected. Please try connecting to the remote computer again.
    • tun on Apple mobile device service failed to start
    • Untoro on Unable to find Adobe PDF resource file. “Acrobat PDFMaker” “You must have administrator privileges to install these files. Please contact your local system administrator.
    • Brian on Apple mobile device service failed to start
  • Amazon Search

  • Sponsors

  • Meta

    • Log in
    • Entries RSS
    • Comments RSS
    • WordPress.org

Tumblog WordPress Themes by Theme created by Obox

English English Afrikaans Afrikaans العربية العربية Беларуская Беларуская български български català català česky česky Cymraeg Cymraeg dansk dansk Deutsch Deutsch ελληνική ελληνική español español eesti eesti فارسی فارسی suomi suomi français français Gaeilge Gaeilge galego galego עברית עברית हिन्दी हिन्दी hrvatski hrvatski magyar magyar bahasa Indonesia bahasa Indonesia íslenska íslenska italiano italiano 日本語 日本語 한국어 한국어 lietuvių lietuvių latviešu latviešu македонски македонски bahasa Melayu bahasa Melayu Malti Malti Nederlands Nederlands norsk norsk polski polski português português română română русский русский slovenčina slovenčina slovenščina slovenščina shqipe shqipe српски српски svenska svenska Kiswahili Kiswahili ภาษาไทย ภาษาไทย Filipino Filipino Türkçe Türkçe українська українська tiếng Việt tiếng Việt ייִדיש ייִדיש 中文 (简体) 中文 (简体) 中文 (繁體) 中文 (繁體) powered byGoogle