Ask A Question

Notifications

You’re not receiving notifications from this thread.

Recurring Select with ice Cube Between Two Dates

spacerobotTR asked in General

Following along with recurring select/ice cube video, I have everything up and running with Rails 7. The only issue I have is that when someone creates an event they set a start_date and an end_date for it. I would like the recurrence to only display the scheduled days until the end_date that is created with the event form. I'm not sure how to do that. Is that on the simple_calendar side with this call:

@calendar_events = @scheduleevents.flat_map{ |e| e.calendar_events(params.fetch(:start_date, Time.zone.now).to_date) }

Or is it set in the model in this section?

def calendar_events(start)
   if recurring.empty?
     [self]
   else
     #start_date = start.beginning_of_month.beginning_of_week
     end_date = start.end_of_month.end_of_week
     schedule(start_date).occurrences(end_date).map do |date|
       Scheduleevent.new(id: id, title: title, start_date: date, end_date: end_date, description: description)
     end
   end
 end
Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 82,969+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.