0

I'm using Ice_cube gem to generate events, and looks fine. The model that implements the recurrency is called "Job" , now I have a list of job, using pagination. I need to sort the Jobs in the list using the next events. The problem is that I'm using find method and will paginate to obtain the jobs . So my question is hoy I can sort the jobs , using the next event like parameter ?

Thanks.

1 Answers1

1

Since the next event (or occurrence in ice_cube terminology) is not a stored field, you will have to sort them in your ruby code.

One way to do that would be:

sorted_jobs = Jobs.all.sort_by&:next_occurrence

Then use sorted_jobs as you wish.

pungoyal
  • 1,768
  • 15
  • 17