bingo bob wrote:
> I need to collect up all the booking dates in an array so that I can do
> stuff with them...
> 
> I figure i need a method in my model to do it...
> 
> something like
> 
>   def self.all_booking_dates
> 
>     find(:all);  # first off find all the booking records
> 
>     @BookedDays = ( XXX ).map # do something here to create an array
> with all the dates in, maybe I need a loop  ... sorry bit stuck?
> 
>   end

To get an array of dates for just one booking, you can build a range and 
then convert it to an array:

(from..to).to_a

To get the array of dates for a set of bookings (such as all bookings), 
I think something like this is what you're looking for:

bookings.map { |b| (b.from..b.to).to_a }.flatten.uniq.sort
-- 
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