Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4540048
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T15:01:55+00:00 2026-05-21T15:01:55+00:00

I’ve updated my server to ruby 1.9.2 and this stopped working (rails 3.0.6): def

  • 0

I’ve updated my server to ruby 1.9.2 and this stopped working (rails 3.0.6):

def index  
  @musicians = Musician.includes(:instruments)
  render :xml => @musicians.to_xml( :include => :instruments )
end

And the models:

class Musician < ActiveRecord::Base
  has_and_belongs_to_many :instruments
end

class Instrument < ActiveRecord::Base
  has_and_belongs_to_many :musicians
end

I’m getting this error:

undefined method `type' for nil:NilClass

Framework trace:

activesupport (3.0.6) lib/active_support/whiny_nil.rb:48:in `method_missing'
activerecord (3.0.6) lib/active_record/serializers/xml_serializer.rb:230:in `compute_type'
activemodel (3.0.6) lib/active_model/serializers/xml.rb:22:in `initialize'
activemodel (3.0.6) lib/active_model/serializers/xml.rb:75:in `new'
activemodel (3.0.6) lib/active_model/serializers/xml.rb:75:in `block in serializable_attributes'

Any clue what I’m doing wrong?

Maybe this is related to: https://rails.lighthouseapp.com/projects/8994/tickets/4840-to_xml-doesnt-work-in-such-case-eventselecttitle-as-tto_xml

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T15:01:56+00:00Added an answer on May 21, 2026 at 3:01 pm

    This is a core issue with Rails. What’s happening is that when Instruments are being included, an instrument_id attribute is getting added. Then, when each Instrument is serialized, the XmlSerializer class determines the type of that attribute based on the Instrument class’ definition, using the type attribute for each column. Since the instrument_id attribute does not exist in the class definition, a nil object is returned which, as of Ruby 1.9, does not have a type attribute, which Rails is depending on.

    (I don’t think the patch in the thread you linked to works — but the one I’ve provided below does.)

    There are two ways to fix this:

    1. Don’t serialize instrument_id (good idea).

      render :xml => @musicians.to_xml( :include => { :instruments => { :except => :instrument_id } } )
    2. Or patch Rails core (bad idea).
      --- a/activerecord/lib/active_record/serializers/xml_serializer.rb  2011-04-20 15:01:10.000000000 -0700
      +++ b/activerecord/lib/active_record/serializers/xml_serializer.rb      2011-04-20 15:00:42.000000000 -0700
      @@ -226,8 +226,10 @@
      
           class Attribute < ActiveModel::Serializers::Xml::Serializer::Attribute #:nodoc:
             def compute_type
      +        Rails.logger.info("key: #{name}, hash: #{@serializable.class.columns_hash[name]}")
               type = @serializable.class.serialized_attributes.has_key?(name) ?
      -          super : @serializable.class.columns_hash[name].type
      +          super : @serializable.class.columns_hash[name].nil? ?
      +            NilClass : @serializable.class.columns_hash[name].type
      
               case type
               when :text
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
I am currently running into a problem where an element is coming back from
Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.