# class Admin::GroupsController

### Public Instance Methods

create() click to toggle source

    # File app/controllers/admin/groups_controller.rb, line 23
    def create
      @group = Group.new(params[:group])
      @group.owner = current_user

      if @group.save
        redirect_to [:admin, @group], notice: 'Group was successfully created.'
      else
        render action: "new"
      end
    end

destroy() click to toggle source

    # File app/controllers/admin/groups_controller.rb, line 64
    def destroy
      @group.destroy

      redirect_to admin_groups_path, notice: 'Group was successfully deleted.'
    end

edit() click to toggle source

    # File app/controllers/admin/groups_controller.rb, line 20
    def edit
    end

index() click to toggle source

    # File app/controllers/admin/groups_controller.rb, line 4
    def index
      @groups = Group.scoped
      @groups = @groups.search(params[:name]) if params[:name].present?
      @groups = @groups.page(params[:page]).per(20)
    end

new() click to toggle source

    # File app/controllers/admin/groups_controller.rb, line 16
    def new
      @group = Group.new
    end

project_update() click to toggle source

    # File app/controllers/admin/groups_controller.rb, line 49
    def project_update
      project_ids = params[:project_ids]
      Project.where(id: project_ids).update_all(group_id: @group.id)

      redirect_to :back, notice: 'Group was successfully updated.'
    end

remove_project() click to toggle source

    # File app/controllers/admin/groups_controller.rb, line 56
    def remove_project
      @project = Project.find(params[:project_id])
      @project.group_id = nil
      @project.save

      redirect_to :back, notice: 'Group was successfully updated.'
    end

show() click to toggle source

    # File app/controllers/admin/groups_controller.rb, line 10
    def show
      @projects = Project.scoped
      @projects = @projects.not_in_group(@group) if @group.projects.present?
      @projects = @projects.all
    end

update() click to toggle source

    # File app/controllers/admin/groups_controller.rb, line 34
    def update
      group_params = params[:group].dup
      owner_id =group_params.delete(:owner_id)

      if owner_id
        @group.owner = User.find(owner_id)
      end

      if @group.update_attributes(group_params)
        redirect_to [:admin, @group], notice: 'Group was successfully updated.'
      else
        render action: "edit"
      end
    end