trabajo-afectivo/app/controllers/tickets_controller.rb

64 lines
1.4 KiB
Ruby
Raw Normal View History

2012-04-10 14:06:46 +00:00
class TicketsController < ApplicationController
before_filter :authentication_check
# GET /tickets
# GET /tickets.json
def index
@tickets = Ticket.all
respond_to do |format|
format.json { render :json => @tickets }
end
end
# GET /tickets/1
# GET /tickets/1.json
def show
@ticket = Ticket.find(params[:id])
respond_to do |format|
format.json { render :json => @ticket }
end
end
# POST /tickets
# POST /tickets.json
def create
@ticket = Ticket.new(params[:ticket])
@ticket.created_by_id = current_user.id
respond_to do |format|
if @ticket.save
format.json { render :json => @ticket, :status => :created }
else
format.json { render :json => @ticket.errors, :status => :unprocessable_entity }
end
end
end
# PUT /tickets/1
# PUT /tickets/1.json
def update
@ticket = Ticket.find(params[:id])
respond_to do |format|
if @ticket.update_attributes(params[:ticket])
format.json { render :json => @ticket, :status => :ok }
else
format.json { render :json => @ticket.errors, :status => :unprocessable_entity }
end
end
end
# DELETE /tickets/1
# DELETE /tickets/1.json
def destroy
@ticket = Ticket.find(params[:id])
@ticket.destroy
respond_to do |format|
format.json { head :ok }
end
end
end