Sha256: b8c0bbb70cccab1b120519784fae07f583c0024fd5992f0629026b04592cd5f8
Contents?: true
Size: 1.49 KB
Versions: 23
Compression:
Stored size: 1.49 KB
Contents
class GroupsController < ApplicationController skip_before_filter :populate_layout, :except => [:edit, :index, :list, :new, :show] def index list render :action => 'list' end # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html) verify :method => :post, :except => [ :edit, :index, :list, :new ], :redirect_to => { :action => :list } def list @groups = Group.paginate({:page => params[:page]}) end def new @group = Group.new end def create @group = Group.new(params[:group]) if @group.save flash[:notice] = 'Group was successfully created.' back_or_redirect_to :action => 'list' else render :action => 'new' end end def edit @group = Group.find(params[:id]) @users = User.find(:all) @members = @group.users.to_s @groups = Group.find(:all, :order => 'name') end def update @group = Group.find(params[:id]) if @group.update_attributes(params[:group]) flash[:notice] = 'Group was successfully updated.' back_or_redirect_to :action => :edit, :id => @group else render :action => 'edit' end end def destroy Group.find(params[:id]).destroy redirect_to :action => 'list' end def set_member @group = Group.find(params[:id]) @user = User.find(params[:user_id]) if params[:value] == 'true' @group.users << @user unless @group.users.include? @user else @group.users.delete @user end @users = User.find(:all) end end
Version data entries
23 entries across 23 versions & 1 rubygems