ruby Simple Rails app与DHTMLX Schedulerhttp://www.dhtmlx.com/docs/products/dhtmlxScheduler/index.shtm

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ruby Simple Rails app与DHTMLX Schedulerhttp://www.dhtmlx.com/docs/products/dhtmlxScheduler/index.shtm相关的知识,希望对你有一定的参考价值。

rails new scheduler
cd scheduler
rails generate scaffold Events text:string details:text start_date:datetime end_date:datetime _timed:boolean
rake db:migrate
class EventsController < ApplicationController
  # GET /events
  # GET /events.json
  def index
    @events = Event.all

    respond_to do |format|
      format.html # index.html.erb
      format.json { render :json => @events }
      format.xml { render :xml => @events.to_xml(:root => "data") }
      # From http://www.dhtmlx.com/docs/products/dhtmlxScheduler/xml/events.xml
    end
  end
  
  # No other methods require XML by the moment
  
  # GET /events/1
  # GET /events/1.json
  def show
    @event = Event.find(params[:id])

    respond_to do |format|
      format.html # show.html.erb
      format.json { render :json => @event }
    end
  end

  # GET /events/new
  # GET /events/new.json
  def new
    @event = Event.new

    respond_to do |format|
      format.html # new.html.erb
      format.json { render :json => @event }
    end
  end

  # GET /events/1/edit
  def edit
    @event = Event.find(params[:id])
  end

  # POST /events
  # POST /events.json
  def create
    @event = Event.new(params[:event])

    respond_to do |format|
      if @event.save
        format.html { redirect_to @event, :notice => 'Event was successfully created.' }
        format.json { render :json => @event, :status => :created, :location => @event }
      else
        format.html { render :action => "new" }
        format.json { render :json => @event.errors, :status => :unprocessable_entity }
      end
    end
  end

  # PUT /events/1
  # PUT /events/1.json
  def update
    @event = Event.find(params[:id])

    respond_to do |format|
      if @event.update_attributes(params[:event])
        format.html { redirect_to @event, :notice => 'Event was successfully updated.' }
        format.json { head :no_content }
      else
        format.html { render :action => "edit" }
        format.json { render :json => @event.errors, :status => :unprocessable_entity }
      end
    end
  end

  # DELETE /events/1
  # DELETE /events/1.json
  def destroy
    @event = Event.find(params[:id])
    @event.destroy

    respond_to do |format|
      format.html { redirect_to events_url }
      format.json { head :no_content }
    end
  end
end
class Event < ActiveRecord::Base
  attr_accessible :_timed, :details, :end_date, :start_date, :text
  
  # From http://www.dhtmlx.com/docs/products/dhtmlxScheduler/xml/events.xml
  def to_xml (options = {})
    options[:indent] ||= 2
    xml = options[:builder] ||= Builder::XmlMarkup.new(:indent => options[:indent])
    xml.instruct! unless options[:skip_instruct]
    xml.event(:id => id, :timed => _timed) do
      xml.text text
      xml.details details
      xml.start_date start_date
      xml.end_date end_date
    end
  end
end

以上是关于ruby Simple Rails app与DHTMLX Schedulerhttp://www.dhtmlx.com/docs/products/dhtmlxScheduler/index.shtm的主要内容,如果未能解决你的问题,请参考以下文章

ruby 在Rails app中设置Locale

ruby 将favicon添加到rails app

ruby new_rails_app.rb

在 Javascript 中执行 ruby​​ 方法 - Ruby on Rails App

Rake doc:app 在升级到 Ruby 2.1.1 和 Rails 4.1 后失败

Opsworks:Rails App Layer:指定 Ruby 次要版本