jQuery、Rails和fullCalendar:如何使用jQuery或fullCalendar在url上设置删除方法

jQuery、Rails和fullCalendar:如何使用jQuery或fullCalendar在url上设置删除方法,jquery,ruby-on-rails,coffeescript,fullcalendar,Jquery,Ruby On Rails,Coffeescript,Fullcalendar,几天来,我一直在思考在Rails 3.2.8上使用fulLCalendar和jQuery可以实现什么 我使用as_json、url访问model/ActiveRecords中的记录,如下所示: class ZigzagPlan < ActiveRecord::Base belongs_to :user has_many :calories_journals attr_accessor :no_of_cycles attr_accessible :zz_type_used,

几天来,我一直在思考在Rails 3.2.8上使用fulLCalendar和jQuery可以实现什么

我使用as_json、url访问model/ActiveRecords中的记录,如下所示:

class ZigzagPlan < ActiveRecord::Base
  belongs_to :user
  has_many :calories_journals

  attr_accessor :no_of_cycles
  attr_accessible :zz_type_used, :normal_mn_ratio_used, :start_date, :no_of_cycles

    # 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.zz_type_used,
            :start => self.start_date.rfc822,
            :end => self.end_date.rfc822,
            :allDay => true,
            :url => Rails.application.routes.url_helpers.zigzag_plan_path(id),  ****
            :color => 'darkGrey',
            textColor: 'white'
        }
    end  
end

使用jquery发送删除请求

 $.ajax({
    url: "/path/to/resource",
    type: "POST",
    data: { _method:'DELETE' },

    success: function(msg) {
        // do something with result
    }
 });
$.ajax({type:“DELETE”,url:“/path/to/resource”,success:function(msg){//do something with result}});这同样有效。建议jQuery方式的Thx。
 $.ajax({
    url: "/path/to/resource",
    type: "POST",
    data: { _method:'DELETE' },

    success: function(msg) {
        // do something with result
    }
 });