Skip to content
Vinicius Stock edited this page Feb 19, 2019 · 2 revisions

Date

Setting

Sail.set(:my_date_setting, "2019-01-01 10:00")
Sail.set(:my_date_setting, DateTime.now)

Getting

Sail.get(:my_date_setting)
=> Tue, 01 Jan 2019 10:00:00 +0000

Sail.get(:my_date_setting) do |setting_value|
  puts setting_value
end
=> Tue, 01 Jan 2019 10:00:00 +0000

Examples

Date settings return a DateTime object. These can be used to define a configurable expiration date for example.

class Promotion < ApplicationRecord
  .
  .
  .

  def expired?
    DateTime.now > Sail.get(:promotion_expiration_date)
  end
end
Clone this wiki locally