bingo bob wrote:
> 
> Thanks, I'll try that.
> 
> I got to here myself, but it's not right ! I think it's close though and 
> I find this syntax easier to read.
> 
> def availability
> 
>   @bookings = Booking.find(:all)
> 
>   for booking in @bookings do
>     bookingfirstday = booking.from.to_date
>     bookinglastday = booking.to.to_date
>     @BookedDays = (bookingfirstday..bookinglastday).map
>   end
> 
> end
> 
> Can you explain why it's wrong ?
> 
> The result is that I @BookedDays only gets set to the last evaluated 
> booking (I think).
> 
> I will try your way though, thanks. (I'd like to get my way working also 
> if poss)?
> 
> Is the loop rewriting @BookedDays each time around rather than adding to 
> it?
> 
> ta

There are a couple problems. The first is that, yes, @BookedDays is 
being rewritten, not appended to. You need to initialize the array 
before the loop starts (@BookedDays = []) and use the += method to 
append to it. Also, you should renamed that variable to @booked_days. 
You can do this with a for-loop, but I suggest getting used to the 
closured-oriented methods in Enumerable and Array. Your code will be 
much more concise and expressive.
-- 
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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to