incorrect block arguments created by each_with_index on active record model
----------------------------------------------------------------------------
Key: JRUBY-2472
URL: http://jira.codehaus.org/browse/JRUBY-2472
Project: JRuby
Issue Type: Bug
Components: ActiveRecord-JDBC
Affects Versions: JRuby 1.1.1
Environment: Mac OS X 10.4.11, JRuby 1.1.1, Rails 2.0.2.9216
Reporter: Stuart Ellidge
Consider the following model classes: order and order_lines.
Order has_many order_lines.
In the view, the following snippet:
<% @order.order_lines.each_with_index do |order_line, index|%>
<%= debug order_line %>
BANG!
<%= debug index %>
<% end %>
Should present a yaml view of an order_line, followed by the text "BANG!",
followed by a yaml view of the current index integer.
However, I instead see the following:
---
- !ruby/object:OrderLine
attributes:
unit_of_measure_id: !str 1
updated_at: 2008-04-29 16:31:39.0
quantity: !str 1
pack_size: dagsagds
product_description: sadgadgs
order_id: !str 6
product_code: sdggs
created_at: 2008-04-29 16:31:39.0
id: !str 10
attributes_cache: {}
- 0
BANG!
---
Which shows that the two block variables are populated with:
1. An array of two elements: one is the order_line, the other is the index
integer.
2. nil
I have tested this with a simple test case and been unable to replicate the
problem - each_with_index appears to work fine from a 'normal' array - but I
consistently see it with ActiveRecord model classes.
--
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