Rails 2.0 to_xml error

I'm trying out the rails 2.0 preview release. Before, I upgraded my Videos table used to serialize to xml with no errors. Now I get this:

Video.find(1)

=> #<Video id: 1, x: 128, y: 96, max_time: 0, max_file: 200000, mp4: false, m3gp: false, m3g2: true, mp3g4: true, h263: false, g264: false, amr: false, aac: false, qclep: true>

Video.find(1).to_xml

ArgumentError: wrong number of arguments (0 for 1)         from /usr/local/lib/ruby/gems/1.8/gems/ activerecord-1.15.3.7707/lib/active_record/serializers/ xml_serializer.rb:292:in `y'         from /usr/local/lib/ruby/gems/1.8/gems/ activerecord-1.15.3.7707/lib/active_record/serializers/ xml_serializer.rb:292:in `send'         from /usr/local/lib/ruby/gems/1.8/gems/ activerecord-1.15.3.7707/lib/active_record/serializers/ xml_serializer.rb:292:in `compute_value'         from /usr/local/lib/ruby/gems/1.8/gems/ activerecord-1.15.3.7707/lib/active_record/serializers/ xml_serializer.rb:247:in `initialize'         from /usr/local/lib/ruby/gems/1.8/gems/ activerecord-1.15.3.7707/lib/active_record/serializers/ xml_serializer.rb:166:in `new'         from /usr/local/lib/ruby/gems/1.8/gems/ activerecord-1.15.3.7707/lib/active_record/serializers/ xml_serializer.rb:166:in `serializable_attributes'         from /usr/local/lib/ruby/gems/1.8/gems/ activerecord-1.15.3.7707/lib/active_record/serializers/ xml_serializer.rb:166:in `collect'         from /usr/local/lib/ruby/gems/1.8/gems/ activerecord-1.15.3.7707/lib/active_record/serializers/ xml_serializer.rb:166:in `serializable_attributes'         from /usr/local/lib/ruby/gems/1.8/gems/ activerecord-1.15.3.7707/lib/active_record/serializers/ xml_serializer.rb:177:in `add_attributes'         from /usr/local/lib/ruby/gems/1.8/gems/ activerecord-1.15.3.7707/lib/active_record/serializers/ xml_serializer.rb:233:in `serialize'         from /usr/local/lib/ruby/gems/1.8/gems/ activesupport-1.4.2.7707/lib/active_support/vendor/builder/xmlbase.rb: 140:in `call'         from /usr/local/lib/ruby/gems/1.8/gems/ activesupport-1.4.2.7707/lib/active_support/vendor/builder/xmlbase.rb: 140:in `_nested_structures'         from /usr/local/lib/ruby/gems/1.8/gems/ activesupport-1.4.2.7707/lib/active_support/vendor/builder/xmlbase.rb: 60:in `method_missing'         from /usr/local/lib/ruby/gems/1.8/gems/ activesupport-1.4.2.7707/lib/active_support/vendor/builder/xmlbase.rb: 32:in `__send__'         from /usr/local/lib/ruby/gems/1.8/gems/ activesupport-1.4.2.7707/lib/active_support/vendor/builder/xmlbase.rb: 32:in `tag!'         from /usr/local/lib/ruby/gems/1.8/gems/ activerecord-1.15.3.7707/lib/active_record/serializers/ xml_serializer.rb:232:in `serialize'         from /usr/local/lib/ruby/gems/1.8/gems/ activerecord-1.15.3.7707/lib/active_record/serialization.rb:91:in `to_s'         from /usr/local/lib/ruby/gems/1.8/gems/ activerecord-1.15.3.7707/lib/active_record/serializers/ xml_serializer.rb:125:in `to_xml'         from (irb):11>>

Here is my videos table if it helps:

class CreateVideos < ActiveRecord::Migration   def self.up     create_table :videos do |t|

    t.column :x, :integer     t.column :y, :integer     t.column :max_time, :integer     t.column :max_file, :integer     t.column :mp4, :boolean     t.column :m3gp, :boolean     t.column :m3g2, :boolean     t.column :mp3g4, :boolean     t.column :h263, :boolean     t.column :g264, :boolean     t.column :amr, :boolean     t.column :aac, :boolean     t.column :qclep, :boolean

    end   end

  def self.down     drop_table :videos   end end

Any ideas?

P.S. to_yaml and to_json work on this object...

Intersterting... If I don't include the y column in the table the serialization works:

    t.column :x, :integer     #t.column :y, :integer     t.column :max_time, :integer     t.column :max_file, :integer     t.column :mp4, :boolean     t.column :m3gp, :boolean     t.column :m3g2, :boolean     t.column :mp3g4, :boolean     t.column :h263, :boolean     t.column :g264, :boolean     t.column :amr, :boolean     t.column :aac, :boolean     t.column :qclep, :boolean

Video.new.to_xml

=> "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<video>\n <aac type= \"boolean\"></aac>\n <amr type=\"boolean\"></amr>\n <g264 type= \"boolean\"></g264>\n <h263 type=\"boolean\"></h263>\n <m3g2 type= \"boolean\"></m3g2>\n <m3gp type=\"boolean\"></m3gp>\n <max-file type=\"integer\"></max-file>\n <max-time type=\"integer\"></max-time> \n <mp3g4 type=\"boolean\"></mp3g4>\n <mp4 type=\"boolean\"></mp4> \n <qclep type=\"boolean\"></qclep>\n <x type=\"integer\"></x>\n</

\n"

Can somebody try to reproduce this? Or is it something special with me.

I'm on osx rails 2.0 via gem install rails --source http://gems.rubyonrails.org

Just to isolate things I created a new project with just one table with one column.

class CreateVideos < ActiveRecord::Migration   def self.up     create_table :videos do |t|       t.integer :x       t.timestamps     end   end

  def self.down     drop_table :videos   end end

This works, but when I rename 'x' to 'y' it .to_xml breaks again:

Video.new.to_xml

ArgumentError: wrong number of arguments (0 for 1)         from /usr/local/lib/ruby/gems/1.8/gems/ activerecord-1.15.3.7707/lib/active_record/serializers/ xml_serializer.rb:292:in `y'         from /usr/local/lib/ruby/gems/1.8/gems/ activerecord-1.15.3.7707/lib/active_record/serializers/ xml_serializer.rb:292:in `send'         from /usr/local/lib/ruby/gems/1.8/gems/ activerecord-1.15.3.7707/lib/active_record/serializers/ xml_serializer.rb:292:in `compute_value'         from /usr/local/lib/ruby/gems/1.8/gems/ activerecord-1.15.3.7707/lib/active_record/serializers/ xml_serializer.rb:247:in `initialize'         from /usr/local/lib/ruby/gems/1.8/gems/ activerecord-1.15.3.7707/lib/active_record/serializers/ xml_serializer.rb:166:in `new'         from /usr/local/lib/ruby/gems/1.8/gems/ activerecord-1.15.3.7707/lib/active_record/serializers/ xml_serializer.rb:166:in `serializable_attributes'         from /usr/local/lib/ruby/gems/1.8/gems/ activerecord-1.15.3.7707/lib/active_record/serializers/ xml_serializer.rb:166:in `collect'         from /usr/local/lib/ruby/gems/1.8/gems/ activerecord-1.15.3.7707/lib/active_record/serializers/ xml_serializer.rb:166:in `serializable_attributes'         from /usr/local/lib/ruby/gems/1.8/gems/ activerecord-1.15.3.7707/lib/active_record/serializers/ xml_serializer.rb:177:in `add_attributes'         from /usr/local/lib/ruby/gems/1.8/gems/ activerecord-1.15.3.7707/lib/active_record/serializers/ xml_serializer.rb:233:in `serialize'         from /usr/local/lib/ruby/gems/1.8/gems/ activesupport-1.4.2.7707/lib/active_support/vendor/builder/xmlbase.rb: 140:in `call'         from /usr/local/lib/ruby/gems/1.8/gems/ activesupport-1.4.2.7707/lib/active_support/vendor/builder/xmlbase.rb: 140:in `_nested_structures'         from /usr/local/lib/ruby/gems/1.8/gems/ activesupport-1.4.2.7707/lib/active_support/vendor/builder/xmlbase.rb: 60:in `method_missing'         from /usr/local/lib/ruby/gems/1.8/gems/ activesupport-1.4.2.7707/lib/active_support/vendor/builder/xmlbase.rb: 32:in `__send__'         from /usr/local/lib/ruby/gems/1.8/gems/ activesupport-1.4.2.7707/lib/active_support/vendor/builder/xmlbase.rb: 32:in `tag!'         from /usr/local/lib/ruby/gems/1.8/gems/ activerecord-1.15.3.7707/lib/active_record/serializers/ xml_serializer.rb:232:in `serialize'         from /usr/local/lib/ruby/gems/1.8/gems/ activerecord-1.15.3.7707/lib/active_record/serialization.rb:91:in `to_s'         from /usr/local/lib/ruby/gems/1.8/gems/ activerecord-1.15.3.7707/lib/active_record/serializers/ xml_serializer.rb:125:in `to_xml'         from (irb):1>>

Strange, something up with 'y'?

Here's the referenced line from the stack trace:

This is calling YAML's Kernel#y method instead of your 'y' attribute.

Attribute reader methods are defined for columns which don't already have a method with the same name. The test for methods with the same name has been in flux and, in this case, is casting too wide a net.

Tobi worked around the problem in http://dev.rubyonrails.org/changeset/7731. The fix will be available in the next preview gem or you can rake rails:freeze:edge to get it now.

Best, jeremy

Thanks for confirming this.

I just ran rake rails:freeze:edge and I still get the error:

Video.new.to_xml

ArgumentError: wrong number of arguments (0 for 1)         from /Users/eggie5/Sites/mms-service/vendor/rails/activerecord/ lib/active_record/serializers/xml_serializer.rb:292:in `y'         from /Users/eggie5/Sites/mms-service/vendor/rails/activerecord/ lib/active_record/serializers/xml_serializer.rb:292:in `send'         from /Users/eggie5/Sites/mms-service/vendor/rails/activerecord/ lib/active_record/serializers/xml_serializer.rb:292:in `compute_value'

I don't think the rails update worked because when i run scrip/console it reports an older rails version:

alex-eggs-computer:~/sites/mms-service eggie5$ script/console Loading development environment (Rails 1.2.4)

What is your RAILS_GEM_VERSION set to?

eggie5 wrote:

alex-eggs-computer:~/sites/mms-service eggie5$ script/console Loading development environment (Rails 1.2.4)

Actually, since you are using the rake method, this variable has no impact. Sorry.

William Pratt wrote:

See my reply to your other post about this. The version number will be updated for official release.

Please file a ticket at http://dev.rubyonrails.org for your .to_xml issue.

Best, jeremy

Can you reproduce this?

Filed bug:

http://dev.rubyonrails.org/ticket/9797

Thanks. Rick just fixed this in http://dev.rubyonrails.org/changeset/7749

jeremy

I just synched to the latest trunk (7754) and I'm still getting the error.

you may try gtk2

Fixed now.