Sha256: f17987d7ea6cfee5a314185e210341e66608cc7f979f6ebe35ac919cfcd5ca76

Contents?: true

Size: 1.46 KB

Versions: 65

Compression:

Stored size: 1.46 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.'
      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)
    redirect_to :action => :edit, :id => @group
  end

end

Version data entries

65 entries across 65 versions & 1 rubygems

Version Path
backlog-0.10.1 app/controllers/groups_controller.rb
backlog-0.10.0 app/controllers/groups_controller.rb
backlog-0.10.5 app/controllers/groups_controller.rb
backlog-0.10.2 app/controllers/groups_controller.rb
backlog-0.10.3 app/controllers/groups_controller.rb
backlog-0.10.4 app/controllers/groups_controller.rb
backlog-0.10.6 app/controllers/groups_controller.rb
backlog-0.10.7 app/controllers/groups_controller.rb
backlog-0.12.0 app/controllers/groups_controller.rb
backlog-0.10.8 app/controllers/groups_controller.rb
backlog-0.11.0 app/controllers/groups_controller.rb
backlog-0.12.1 app/controllers/groups_controller.rb
backlog-0.12.2 app/controllers/groups_controller.rb
backlog-0.12.4 app/controllers/groups_controller.rb
backlog-0.12.3 app/controllers/groups_controller.rb
backlog-0.13.0 app/controllers/groups_controller.rb
backlog-0.13.1 app/controllers/groups_controller.rb
backlog-0.2.0 app/controllers/groups_controller.rb
backlog-0.2.1 app/controllers/groups_controller.rb
backlog-0.3.0 app/controllers/groups_controller.rb