-
Notifications
You must be signed in to change notification settings - Fork 358
IceCube and Rails
Andrew Vit edited this page Nov 24, 2013
·
5 revisions
If you are using Bundler include ice_cube by adding gem 'ice_cube'
to your Gemfile and running bundle install
.
For convenience, you may add include IceCube
inside the top of your ActiveRecord model to access the IceCube classes more easily without needing to prefix the IceCube::
namespace.
For example:
class Task < ActiveRecord::Base
include IceCube
def schedule
Schedule.new(start_date) do |s|
s.add_recurrence_rule Rule.daily(1).count(7)
end
end
end
To save and reload your schedule in ActiveRecord with the attribute name 'schedule', you should set up a TEXT database column and add the serializer for the column name:
class Task < ActiveRecord::Base
serialize :schedule, IceCube::Schedule
end
This will save your schedule in YAML format.