ice_cube and recurring_select gems and occurrences

元气小坏坏 提交于 2019-12-04 04:35:27

After consulting John Crepezzi (author of the ice_cube gem – thanks John!), I found that I was storing the rule for the recurrences as opposed to the schedule itself. The following code fixed the issue:

serialize :schedule, Hash

def schedule=(new_schedule)
  write_attribute(:schedule, RecurringSelect.dirty_hash_to_rule(new_schedule).to_hash)
end

def converted_schedule
  the_schedule = Schedule.new(self.start_date)
  the_schedule.add_recurrence_rule(RecurringSelect.dirty_hash_to_rule(self.schedule))
  the_schedule
end

Note: I also switched to storing that column as a hash instead of YAML as previously posted.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!