trabajo-afectivo/app/controllers/groups_controller.rb

49 lines
922 B
Ruby
Raw Normal View History

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