Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/60.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails Rails jquery fullcalendar可以';t在事件中显示额外字段_Ruby On Rails_Fullcalendar - Fatal编程技术网

Ruby on rails Rails jquery fullcalendar可以';t在事件中显示额外字段

Ruby on rails Rails jquery fullcalendar可以';t在事件中显示额外字段,ruby-on-rails,fullcalendar,Ruby On Rails,Fullcalendar,我正在rails应用程序中使用jquery fullcalendar。 当前,它在月份显示中显示event.title字段。我希望它也能显示和附加field=workorder.wonum 我在Stackoverflow上找到了这个解决方案 eventRender: (event, element) -> element.find(".fc-event-title").html(event.title + ": <span>" + event.workorder.wonum

我正在rails应用程序中使用jquery fullcalendar。 当前,它在月份显示中显示event.title字段。我希望它也能显示和附加field=workorder.wonum

我在Stackoverflow上找到了这个解决方案

eventRender: (event, element) ->
  element.find(".fc-event-title").html(event.title + ": <span>" + event.workorder.wonum + "</span>")

谢谢

我终于明白了

解决方案是将workorder.wonum与标题结合起来:

 # 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.workorder.wonum} #{self.title}",
    :description => self.description || "",
    :start => starts_at.rfc822,
    :end => ends_at.rfc822,
    :allDay => self.all_day,
    :recurring => false,
    :url => Rails.application.routes.url_helpers.event_path(id),
    :color => "blue",
    :backgroundColor => "blue",
    :borderColor => "black",
    :textColor  => "white"
 }

end

在上面的代码中,您有
event.workorder\u num
,而不是
\u id
??我的打字错误-谢谢您指出-我更新了问题
 # 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.workorder.wonum} #{self.title}",
    :description => self.description || "",
    :start => starts_at.rfc822,
    :end => ends_at.rfc822,
    :allDay => self.all_day,
    :recurring => false,
    :url => Rails.application.routes.url_helpers.event_path(id),
    :color => "blue",
    :backgroundColor => "blue",
    :borderColor => "black",
    :textColor  => "white"
 }

end