0

I'm using recurring_select and ice_cube to let the user define recurring events. I'm storing the serialized IceCube-Schedule in a string-Attribute.

The event-Model includes this code:

include IceCube
serialize :schedule, IceCube::Schedule

The Controller is sanitizing the Input:

params[:event][:schedule] = JSON.parse(params[:event][:schedule], quirks_mode: true)

The view looks like this:

= simple_form_for [:admin, @event] do |f|
  = f.input :schedule do
    = f.select_recurring :schedule

This is what the params look after sanitizing for an Event recurring each day:

{"schedule"=>{"interval"=>1, "until"=>nil, "count"=>nil, "validations"=>nil, "rule_type"=>"IceCube::DailyRule"}}

But after assigning this to a new event using Event.new, inspecting the schedule looks like this:

#<IceCube::Schedule:0x007f762831e958 @start_time=2015-12-17 12:02:29 +0100, @all_recurrence_rules=[], @all_exception_rules=[]>

The recurring rules seem to be gone and the form-field only displays the date and time.

secador de pelo
  • 687
  • 5
  • 26

1 Answers1

1

I had the same problem. recurring_select only edits the rule. Following solved the problem for me:

schedule = IceCube::Schedule.new (start_time = params['schedule_starttime'])
schedule.add_recurrence_rule( RecurringSelect.dirty_hash_to_rule(params['schedule_rule']) )

schedule_starttime and schedule_rule are not stored in the db, schedule will.