标签: ice-cube

ice_cube和recurring_select宝石和事件

我正在尝试利用ice_cube和recurring_select宝石的[超棒]功能来处理重复发生的事件.我的schedule数据库中有一个(文本)列,事件模型中有以下内容:

  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 
Run Code Online (Sandbox Code Playgroud)

查看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
Run Code Online (Sandbox Code Playgroud)

但是,当我尝试输出时converted_schedule,它只显示开始日期,不会显示任何其他日期.我有一些怀疑,我没有成功,但是YAML没有正确地转换为converted_schedule方法?也许我需要一个结束日期(我没有看到recurring_select上这个功能可用的地方)?

ruby-on-rails ice-cube

8
推荐指数
1
解决办法
2207
查看次数

在给定时间段内有效地检索ice_cube计划

我正在考虑使用Ice Cube https://github.com/seejohnrun/ice_cube进行重复活动.我的问题是,如果我需要获得任何属于给定时间段内的事件(例如,在一天或一周内),是否有更好的方法来循环它们所有这样:

items = Records.find(:all)
items.each do |item|
  schedule = item.schedule
  if schedule.occurs_on?(Date.new)
      #if today is a recurrence, add to array
  end
end
Run Code Online (Sandbox Code Playgroud)

这看起来效率非常低,但我不知道怎么回事.

ruby-on-rails ruby-on-rails-3 ice-cube

6
推荐指数
1
解决办法
1644
查看次数

在IRB中使用ice_cube Ruby gem

我正在尝试在IRB中使用名为ice_cube的Ruby gem ,但它不起作用:

[~]$ rvm gemset create ice
'ice' gemset created (/home/joe/.rvm/gems/ruby-1.9.2-p320@ice).

[~]$ rvm gemset use ice
Using ruby-1.9.2-p320 with gemset ice

[~]$ gem install ice_cube
Fetching: ice_cube-0.8.0.gem (100%)
Successfully installed ice_cube-0.8.0
1 gem installed
Installing ri documentation for ice_cube-0.8.0...
Installing RDoc documentation for ice_cube-0.8.0...

[~]$ irb --simple-prompt
>> require 'ice_cube'
=> true

>> schedule = Schedule.new(Time.now)
NameError: uninitialized constant Object::Schedule
    from (irb):2
    from /home/joe/.rvm/rubies/ruby-1.9.2-p320/bin/irb:16:in `<main>'
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么?(我是初学Ruby程序员.)

ruby gem irb ice-cube

6
推荐指数
1
解决办法
905
查看次数

用于复原事件的gem ice_cube

我有简单的事件模型(标题,日期,用户)我创建了几个月的事件日历(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
Run Code Online (Sandbox Code Playgroud)

1)我如何将重复规则与Events数组相结合?

2)据我所知,我可以在yaml yaml = schedule.to_yaml中保存有关重复的db信息

但我不清楚如何为重复创建下拉列表(没有,每天,每个月,每年),并将其与shedule规则联系起来.我应该在哪里以及如何实现它(将用户选择转换为正确的)

gem calendar ruby-on-rails repeat ice-cube

5
推荐指数
1
解决办法
1794
查看次数

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

这里必须有一些简单的东西被忽视......

我一直在尝试各种方法来创建基本的IceCube时间表(https://github.com/seejohnrun/ice_cube).总体目标是使用IceCube"房间预订"rails应用程序中的"价格表".

第一种情况是创建schedule一个特定的基础start_timeend_time- 只发生一次.IceCube能做到这一点,对吗?

时间表将从start_time结束时开始end_time.我希望能够检查occurs_on?此日程表的日期或时间,以确定是否应调整房价.

因此,在控制台我试着建立一个基本的时间表,并希望它可以发生5.days从现在开始,因为start_timeTime.nowend_timeTime.now + 30.days.但它似乎永远不会真实......

1.8.7 :001 > schedule = IceCube::Schedule.new(Time.now, :end_time => Time.now + 30.days)
 => #<IceCube::Schedule:0xb619d604 @all_recurrence_rules=[], @duration=nil, @end_time=Tue Jan 08 09:13:11 -0600 2013, @all_exception_rules=[], @start_time=Sun Dec 09  09:13:11 -0600 2012> 
1.8.7 :002 > schedule.occurs_on? Date.today + 5.days
 => false 
1.8.7 :005 > schedule.occurs_at? Time.now …
Run Code Online (Sandbox Code Playgroud)

ruby ruby-on-rails-3 ice-cube

3
推荐指数
1
解决办法
2916
查看次数

标签 统计

ice-cube ×5

ruby-on-rails ×3

gem ×2

ruby ×2

ruby-on-rails-3 ×2

calendar ×1

irb ×1

repeat ×1