Gem ice_cube for repeat events

I have a simple event model (name, date, user) And I created a monthly calendar of events (gem 'watu_table_builder'). I need a function to create repeating events. I realized that I can use gem ice_cube for this. But this is not clear to me.

I added to the model:

class Event < ActiveRecord::Base
  #require 'ice_cube'
  include IceCube

  belongs_to :user

  validates :title, :presence => true,
                    :length => { :minimum => 5 }
  validates :shedule, :presence => true

  def self.events_and_repeats(date)
    @events = Event.where(shedule:date.beginning_of_month..date.end_of_month)

# Here I need to figure out what is events repeats at this month (from date param)
# how I may combine it with Events array

    @events_repeats = @events # + repeats

    return @events_repeats

  end

1) How can I combine repeat rules with the Events array?

2) As far as I understand, I can save repetition information in db in yaml yaml = schedule.to_yaml

But itโ€™s not clear to me how this is a good way to create a drop-down list for replays (not a single one, every day, every month, every year) and not associate it with schedule rules. Where and how should I understand this (convert user selection to the correct schedule)

+5
1

Event serialized (yaml), , , . , schedule.occurrences : , .

, , schedule_attributes gem, ( ...)

+1

All Articles