- @reports.to_enum.with_index(1).each do |r, i|
- r.alerts.reverse.each do |a|
- if a.code == 14
%tr
%td.num_col Trip #{i}
%td.start_col #{r.time}
%td.end_col
%td.distance_col #{0}
i should equal 1 during first iteration. However, it is equal to 20
during every iteration. Not sure what''s going on.
thanks for response
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
Maybe the title of this post sounds crazy but its true.
- iterate_for(@reports)
- @reports.to_enum.with_index(1).each do |r, i|
- r.alerts.reverse.each do |a|
- if a.code == 14
%tr
%td.num_col Trip #{i}
- elsif a.code == 15
%tr
%td.num_col Trip #{i}
def iterate_for(reports)
Rails.logger.info "THe value of reports is #{reports}"
Rails.logger.info "The length of reports i #{reports.size}"
reports.to_enum.with_index(1).each do |r,i|
Rails.logger.info "The report is #{r}"
Rails.logger.info "The count is #{i}"
end
end
I created an iterate_for method just to see what happens when I log
the output in a helper to the console. And the with_index method
correctly sets the value of i to 1 and so forth. But within the haml,
this:
Trip #{i}
i is equal to the value 20 every time.
Im not sure what''s going on.
thanks for response
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
After typing second message, I realized the nested loop was causing the issue. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.