trabajo-afectivo/app/controllers/roles_controller.rb

56 lines
978 B
Ruby
Raw Normal View History

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