Hi!
I''m trying to create a nested hash which should hold the dates
in my database as a kind of calendar. What I did so far is obviously
wrong,
because I''m storing the week-number for every day in the week array.
I don''t really understand nested hashes and can''t find the
solution.
what am I doing wrong here?? What''s the right way of doing this??
11 @calendar = Hash.new{|h,k| h[k]=Hash.new(&h.default_proc) }
12 week = []
13 Dates.find(:all).each do |row|
14 date = Date.strptime(str="#{row.dato}")
15 year = date.cwyear
16 month = date.mon
17 week << date.cweek
18 @calendar[year][month] = week
19 end
thanks in advance,
floke
--
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-/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.