1

私はrails3.2.5でFullCalendarを使用しました。私はmongodibgemでmongodbデータベースを使用しました。イベントを作成したとき、そのようなイベントはカレンダーに表示されません。私のモデル(event.rb)は次のとおりです

class Event
  include Mongoid::Document
  field :title, type: String
  field :starts_at
  field :ends_at
  field :all_day, type: Boolean
  field :description, type: String
  scope :before, lambda {|end_time| {:conditions => ["ends_at < ?", Event.format_date(end_time)] }}
  scope :after, lambda {|start_time| {:conditions => ["starts_at > ?", Event.format_date(start_time)] }}

  # need to override the json view to return what full_calendar is expecting.
  # http://arshaw.com/fullcalendar/docs/event_data/Event_Object/
  def as_json(options = {})
    {
      :id => self.id,
      :title => self.title,
      :description => self.description || "",
      :start => starts_at,
      :end => ends_at,
      :allDay => self.all_day,
      :recurring => true,
      :url => Rails.application.routes.url_helpers.event_path(id)
    }

  end

  def self.format_date(date_time)
    Time.at(date_time.to_i).to_formatted_s(:db)
  end
end

どうすればこの問題を解決できますか。私を助けてください。前もって感謝します。

4

1 に答える 1