Hi
I’ve been trying to get the following code to work. I’m sure it must
be something simple. As you can see, the session is forced to hold the
value of ‘week’.
I simply need to check if the value session[:calview] is day. If it
isn’t then it’ll store 7 days into an array.
I’ve put the code into my controller and it simply won’t go to the
‘else’ statement. I’ve left in the logger.warn statements for you to
see. I’ve even tried to use a different variable just in case I was
doing something to session.
session[:calview] = “week”
currentcalview = session[:calview]
logger.warn(“Session holds (new): #{currentcalview}”)
if currentcalview = ‘day’
#Just list the calendar for one day
@dates = session[:dateviewing]
logger.warn (“I am inside the day viewer with date #{@dates}”)
else
#Means we wish to look at the week
@dates = []
startdate = session[:dateviewing]
curdate = startdate
enddate = startdate + 7.days
logger.warn(“I am inside the week viewer: Curdate #{curdate} End
Date: #{enddate}”)
while curdate < enddate do
@dates.push(curdate)
curdate += 1.day
end
logger.warn(“I am here with the following date(s) for the week
#{@dates}”)
end
I’m sure there are nicer ways of putting 7 dates into an array given a
start date but I’m trying to cobble together bits of code from a
(short!) lifetime of pascal, c, vb, php, perl and lots of others! My
brains’ not coping too well as you can see! Any help to make the code
“nicer” would also be appreciated.
Any help in trying to work out what I’m doing wrong greatly
appreciated.
Cheers
Darren