Use JSON date serializer

Effective API changes:

  - nil serializes to null, not empty string
  - dates serialize to IETF RFC 3339 with millisecond precision, not
    second precision surrounded by spaces
This commit is contained in:
Andrew Kvalheim 2022-09-28 09:34:01 -07:00
parent b60257ef59
commit 397341a324
4 changed files with 8 additions and 15 deletions

View file

@ -3,12 +3,8 @@
class EventScheduleSerializer < ActiveModel::Serializer
include ActionView::Helpers::TextHelper
attributes :date, :room
def date
t = object.start_time
t.blank? ? '' : %( #{I18n.l t, format: :short}#{t.formatted_offset(false)} )
end
attribute :start_time, key: :date
attributes :room
def room
object.room.guid