Tuesday, October 23, 2012

[Rails] multidimensional Array or Hash with group_by 'created_at'

Hello,
i want to create a multidimensional Array or Hash with group_by
'created_at'.

3 dimensions needed:
myArray[week][day][data]

currently i only created it with 2 dimesions:

#model
def self.group_per_day
all.group_by{|t| t.created_at.strftime("%d. %B, %Y")}.sort #"%U" for
Weeks
end

#controller
@pdf_activities = Activity.group_per_day

#view
-@pdf_activities.each do |day|
=day[0]
-day[1].each do |activity|
=activity.activity

thanks

--
Posted via http://www.ruby-forum.com/.

--
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@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate