Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

96 lines (78 sloc) 2.12 kB
class GroupsController < ApplicationController
before_filter :login_required, :except => [:index, :show]
# GET /groups
# GET /groups.xml
def index
@groups = Group.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @groups }
end
end
# GET /groups/1
# GET /groups/1.xml
def show
@group = Group.find_by_permalink(params[:permalink], :include => [:users])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @group }
end
end
# GET /groups/new
# GET /groups/new.xml
def new
@group = Group.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @group }
end
end
# GET /groups/1/edit
def edit
@group = Group.find(params[:id])
end
# POST /groups
# POST /groups.xml
def create
@group = Group.new(params[:group])
respond_to do |format|
if @group.save
flash[:notice] = 'Group was successfully created.'
format.html { redirect_to(@group) }
format.xml { render :xml => @group, :status => :created, :location => @group }
else
format.html { render :action => "new" }
format.xml { render :xml => @group.errors, :status => :unprocessable_entity }
end
end
end
# PUT /groups/1
# PUT /groups/1.xml
def update
@group = Group.find(params[:id])
respond_to do |format|
if @group.update_attributes(params[:group])
flash[:notice] = 'Group was successfully updated.'
format.html { redirect_to(@group) }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @group.errors, :status => :unprocessable_entity }
end
end
end
# DELETE /groups/1
# DELETE /groups/1.xml
def destroy
@group = Group.find(params[:id])
@group.destroy
respond_to do |format|
format.html { redirect_to(groups_url) }
format.xml { head :ok }
end
end
protected
def authorized?
logged_in? && admin?
end
end
Jump to Line
Something went wrong with that request. Please try again.