jruby behaves differently from MRI with (rails 2.3.8) activerecord associations
-------------------------------------------------------------------------------
Key: JRUBY-4844
URL: http://jira.codehaus.org/browse/JRUBY-4844
Project: JRuby
Issue Type: Bug
Components: Ruby 1.8.7
Affects Versions: JRuby 1.5
Environment: ubuntu 9.10 64bit
Reporter: Mathijs Kwik
Priority: Minor
I created a small demo rails project.
2 models, Post and Comment, Post has many comments.
MRI:
>> p=Post.first
=> #<Post id: 1, title: "hello rails", body: nil, created_at: "2010-06-04
07:43:07", updated_at: "2010-06-04 07:43:07">
>> p.comments.each_with_index {|c, i| puts [c,i].inspect}
[#<Comment id: 1, post_id: 1, body: "comment 1", created_at: "2010-06-04
07:43:16", updated_at: "2010-06-04 07:43:16">, 0]
[#<Comment id: 2, post_id: 1, body: "comment 2", created_at: "2010-06-04
07:43:45", updated_at: "2010-06-04 07:43:45">, 1]
[#<Comment id: 3, post_id: 1, body: "comment 3", created_at: "2010-06-04
07:43:47", updated_at: "2010-06-04 07:43:47">, 2]
JRUBY:
>> p=Post.first
=> #<Post id: 1, title: "hello rails", body: nil, created_at: "2010-06-04
07:43:07", updated_at: "2010-06-04 07:43:07">
>> p.comments.each_with_index {|c, i| puts [c,i].inspect}
[[#<Comment id: 1, post_id: 1, body: "comment 1", created_at: "2010-06-04
07:43:16", updated_at: "2010-06-04 07:43:16">, 0], nil]
[[#<Comment id: 2, post_id: 1, body: "comment 2", created_at: "2010-06-04
07:43:45", updated_at: "2010-06-04 07:43:45">, 1], nil]
[[#<Comment id: 3, post_id: 1, body: "comment 3", created_at: "2010-06-04
07:43:47", updated_at: "2010-06-04 07:43:47">, 2], nil]
as you can see, jruby doesn't throw 2 block parameters at each_with_index, but
instead packs them in an array and passes them as 1 argument.
each_with_index behaviour on normal enumerables works OK, so it's probably due
to some heavy metaprogramming in activerecord.
Nonetheless, I would expect jruby to respond the same.
--
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