Sha256: 9829b0220b40655dfea65df9cab93a4f6e57f80eb9bacd8631fe0c7114eaaee7
Contents?: true
Size: 1.41 KB
Versions: 4
Compression:
Stored size: 1.41 KB
Contents
class GroupsController < ApplicationController 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 @group_pages, @groups = paginate :groups, :per_page => 10 end def new @group = Group.new end def create @group = Group.new(params[:group]) if @group.save flash[:notice] = 'Group was successfully created.' 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 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) redirect_to :action => :edit, :id => @group end end
Version data entries
4 entries across 4 versions & 1 rubygems