calendar hash

J

Jule Nissen

Posted this in the rails group, but didn't get an answer yet.
maybe you can help me?

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,705
Latest member
Stefkari24

Latest Threads

Top