Listing 3. appointments_controller.rb class AppointmentsController < ApplicationController def index render :json => Appointment.all end def show render :json => Appointment.find(params[:id]) end def new @appointment = Appointment.new end def edit @appointment = Appointment.find(params[:id]) end def create params.delete('action') params.delete('controller') @appointment = Appointment.new(params) if @appointment.save render :json => 'Appointment was successfully created.' else render :json => 'Error creating appointment.' end end def update @appointment = Appointment.find(params[:id]) if @appointment.update_attributes(params[:appointment]) render :json => 'Appointment was successfully updated.' else render :json => 'Error updating appointment.' end end def destroy @appointment = Appointment.find(params[:id]) @appointment.destroy render :json => "Appointment destroyed." end end