YAML doesn't like serializing ActiveRecord has many associations
----------------------------------------------------------------
Key: JRUBY-2013
URL: http://jira.codehaus.org/browse/JRUBY-2013
Project: JRuby
Issue Type: Bug
Components: Core Classes/Modules
Affects Versions: JRuby 1.1RC1
Environment: MySQL, Can reproduce with Oracle as well
Reporter: K Venkatasubramaniyan
I have run into a YAML issue that took sometime to reduce it to a simpler test
case.
Here is the issue stack trace:
/home/someuser/some_app/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb:38:in
`quote': undefined method `value' for #<String:0x614a7> (NoMethodError)
from
/home/someuser/jruby-1.1RC1/lib/ruby/gems/1.8/gems/activerecord-jdbc-adapter-0.7.1/lib/jdbc_adapter/jdbc_mysql.rb:81:in
`quote'
from
/home/someuser/some_app/vendor/rails/activerecord/lib/active_record/base.rb:2055:in
`quote_value'
from
/home/someuser/some_app/vendor/rails/activerecord/lib/active_record/base.rb:2044:in
`attributes_with_quotes'
from
/home/someuser/some_app/vendor/rails/activerecord/lib/active_record/base.rb:2034:in
`inject'
from
/home/someuser/some_app/vendor/rails/activerecord/lib/active_record/base.rb:2034:in
`each'
from
/home/someuser/some_app/vendor/rails/activerecord/lib/active_record/base.rb:2034:in
`inject'
from
/home/someuser/some_app/vendor/rails/activerecord/lib/active_record/base.rb:2034:in
`attributes_with_quotes'
from
/home/someuser/some_app/vendor/rails/activerecord/lib/active_record/base.rb:2034:in
`attributes_with_quotes'
... 13 levels...
from
/home/someuser/some_app/vendor/rails/activerecord/lib/active_record/transactions.rb:129:in
`save_with_dirty'
from
/home/someuser/some_app/vendor/rails/activerecord/lib/active_record/associations/association_proxy.rb:123:in
`method_missing'
from (eval):4:in `eval'
...internal jruby stack elided...
Here are simpler steps to reproduce the problem:
Define a couple of AR Models called Model A and Model B. Make the relationship
ModelA has_many ModelB. Throw a record in the parent model and put some related
records in the child model.
Now in script/console type the following:
a_record = ModelA.find(1)
a_record.model_bs # (Just display the child collection)
a.to_yaml
This should result in the exception
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email