I have an action in a controller where I want to generate a batch of 10 consecutive days for each request.
I keep track of where we are in the batch cycle by passing a variable page
, for each batch.
The cycle of batches should start with today.
How can I express this in the simplest way?
Right now I have the following mess, which doesn't even work (each batch, except for the first one, start one day too early):
@page_number = (params[:page_number] || 0).to_i + 1
today = Date.today
batch_amount = 10
first_day_of_current_batch = today + (batch_amount * (@page_number - 1))
days = first_day_of_current_batch..(first_day_of_current_batch + batch_amount)