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:insend’
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:ininitialize’
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:inserializable_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:inserializable_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:inserialize’
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:insend
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:inserialize’
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:into_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

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:insend’
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:ininitialize’
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:inserializable_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:inserializable_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:inserialize’
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:insend
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:inserialize’
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:into_xml’
from (irb):1>>

Strange, something up with ‘y’?

Here’s the referenced line from the stack trace:

On 10/4/07, eggie5 [email protected] wrote:

activerecord-1.15.3.7707/lib/active_record/serializers/
xml_serializer.rb:292:in `y’

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

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:insend’
from /Users/eggie5/Sites/mms-service/vendor/rails/activerecord/
lib/active_record/serializers/xml_serializer.rb:292:in `compute_value’

Thanks for confirming this.

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)


  * config.breakpoint_server has been deprecated and has no

effect. *


Video.new.to_xml

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


  * config.breakpoint_server has been deprecated and has no

effect. *


RAILS_GEM_VERSION
=> “1.2.3”

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

William P. wrote:


    from /Users/eggie5/Sites/mms-service/vendor/rails/activerecord/

Video.find(1)
xml_serializer.rb:292:in `y’

William P.


Sincerely,

William P.

What is your RAILS_GEM_VERSION set to?

eggie5 wrote:

On Oct 5, 2:17 am, “Jeremy K.” [email protected] wrote:

false, m3gp: false, m3g2: true, mp3g4: true, h263: false, g264: false,


Sincerely,

William P.

On 10/5/07, eggie5 [email protected] wrote:

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

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

Filed bug:

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

Can you reproduce this?

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

On 10/5/07, eggie5 [email protected] wrote:

Filed bug:

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

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

jeremy

you may try gtk2

Fixed now.