我将 FullCalendar 与 rails3.2.5 一起使用。我将 mongodb 数据库与 mongoid gem 一起使用。当我创建事件时,这些事件不会出现在日历中。我的模型(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
我怎么解决这个问题。请帮我。提前致谢。