module Resa
  class Event
    include Mongoid::Document
    include Mongoid::Timestamps
    field :title,       :type => String
    field :dtstart,     :type => DateTime
    field :dtend,       :type => DateTime

    belongs_to :location, class_name: 'Resa::Location', inverse_of: :event
    belongs_to :organizer, class_name: 'MongoidUser', inverse_of: :events
    accepts_nested_attributes_for :organizer

    # Convert event to iCalendar
    def to_ics
      event = Icalendar::Event.new

      event.start         = self.dtstart
      event.end           = self.dtend
      event.summary       = self.title
      event.organizer     = self.organizer
      event.location      = self.location.name

      event
    end

  end
end

module Resa
  class Event
    include Mongoid::Document
    include Mongoid::Timestamps
    field :title,       :type => String
    field :dtstart,     :type => Time
    field :dtend,       :type => Time

    belongs_to :location, class_name: 'Resa::Location', inverse_of: :event
    belongs_to :organizer, class_name: 'MongoidUser', inverse_of: :events
    accepts_nested_attributes_for :organizer

    # Convert event to iCalendar
    def to_ics
      event = Icalendar::Event.new

      event.start         = self.dtstart
      event.end           = self.dtend
      event.summary       = self.title
      event.organizer     = self.organizer
      event.location      = self.location.name

      event
    end

  end
end

Use Time instead of DateTime (again)
Use Time instead of DateTime (again)

for speed and bugged with mongoid:
see https://github.com/mongoid/mongoid/issues/1135

Signed-off-by: Laurent Arnoud <f1b010126f61b5c59e7d5eb42c5c68f6105c5914@spkdev.net>
