シンプルなイベント モデル (タイトル、日付、ユーザー) があり、月ごとにイベント カレンダーを作成しました (gem 'watu_table_builder')。繰り返しイベントを作成する機能が必要です。gem ice_cube を使用できることがわかりました。しかし、それは私には明らかではありません。
モデルに追加しました:
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) 繰り返しルールとイベント配列を組み合わせるにはどうすればよいですか?
2)私が理解しているように、yaml yaml = schedule.to_yaml の繰り返しに関する情報をデータベースに保存することがあります
しかし、繰り返しのドロップダウン (なし、毎日、毎月、毎年) を作成し、それをスケジュール ルールにリンクする方法がどのように良いかは、私には明確ではありません。どこでどのように実現すればよいか (ユーザーの選択を適切なスケジュールに変換)