Tag: 冰块

ice_cube和recurring_selectgem和事件

我正在尝试利用ice_cube和recurring_selectgem的[超棒]function来处理重复发生的事件。 我的数据库中有一个schedule (text)列,事件模型中有以下内容: def schedule=(new_schedule) write_attribute(:schedule, RecurringSelect.dirty_hash_to_rule(new_schedule).to_yaml) end def converted_schedule Schedule.from_yaml(self.schedule, :start_date_override => self.start_date) end 查看psql中的schedule列,它似乎正确地存储了日程表。 这是我的表格: .control-group = f.label ‘Date’, :class => ‘control-label’ .controls = f.text_field :start_date, :class => ‘datepicker’ .control-group = f.label ‘Recurring?’, :class => ‘control-label’ .controls = f.select_recurring :schedule, :allow_blank => true 但是,当我尝试输出converted_schedule ,它只显示开始日期,不会显示任何其他日期。 我有一些怀疑,我没有成功修改…也许YAML没有正确转换为converted_schedule方法? 也许我需要一个结束日期(我不知道recurring_select上有哪些function可用)?

用于复原事件的gem ice_cube

我有简单的事件模型(标题,日期,用户)我创建了几个月的事件日历(gem’watu_table_builder’)。 我需要该function来创建重复事件。 我发现我可能会使用gem ice_cube。 但我不清楚。 我添加到模型: class Event 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 […]

使用start_time和end_time使用ice_cube gem发生单次事件

这里必须有一些简单的东西被忽视…… 我一直在尝试各种方法来创建基本的IceCube计划( https://github.com/seejohnrun/ice_cube )。 总体目标是使用IceCube在“房间预订”rails应用程序中允许“价格表”。 第一种情况是创建具有特定start_time和end_time的基本schedule – 仅发生一次。 IceCube可以做到这一点,对吗? 计划将在start_time开始,并在end_time结束。 我希望能够检查日期或时间是否发生occurs_on? 此计划确定是否应调整房价。 所以在控制台中我尝试创建一个基本的时间表,并且预计它将从现在开始发生5.days ,因为start_time是Time.now而end_time是Time.now + 30.days 。 但它似乎永远不会真实…… 1.8.7 :001 > schedule = IceCube::Schedule.new(Time.now, :end_time => Time.now + 30.days) => # 1.8.7 :002 > schedule.occurs_on? Date.today + 5.days => false 1.8.7 :005 > schedule.occurs_at? Time.now + 5.days => false 1.8.7 :006 > schedule.occurring_at? Time.now + […]