5

I have simple Event model (title, date, user) And I created Events Calendar by months (gem 'watu_table_builder'). I need the feature to create repeating events. I figured out that I may use gem ice_cube for it. But it is not clear for me.

I added to 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 I may combine repeat rules with Events array?

2) As I understand, I may save to db information about repeats in yaml yaml = schedule.to_yaml

But it is not clear for me how it is good way to create drop-down for repeats (none, each day, each month, each year) and link it with shedule rules. Where and how I should realize it (convert user choise to right shedule)

4

1 回答 1

1

如果您正在尝试这样做,您将无法查询数据库以获取事件的序列化 (yaml) 计划以按月过滤事件。如果您需要这样做,那么您必须将schedule.occurrencesas 行存储在单独的表连接中:这就是我在我们的应用程序中所做的。

稍后我可能有更多细节要添加到这个答案中,同时看看我的schedule_attributes gem,如果它可以帮助您构建选择器以从用户输入构建时间表(我仍然需要更新文档并发布它......)

于 2013-04-05T19:40:42.283 回答