Class: Guts::GroupsController

Inherits:
ApplicationController show all
Includes:
ControllerPermissionConcern
Defined in:
app/controllers/guts/groups_controller.rb

Overview

Groups controller

Instance Method Summary collapse

Methods inherited from ApplicationController

#current_ability

Methods included from MultisiteConcern

#current_site, #with_current_site

Instance Method Details

#createObject

Note:

Redirects to #index if successfull or re-renders #new if not

Creates a group through post



31
32
33
34
35
36
37
38
39
40
# File 'app/controllers/guts/groups_controller.rb', line 31

def create
  @group = Group.new group_params

  if @group.save
    flash[:notice] = 'Group was successfully created.'
    redirect_to edit_group_path(@group)
  else
    render :new
  end
end

#destroyObject

Note:

Redirects to #index on success

Destroys a group



55
56
57
58
59
60
# File 'app/controllers/guts/groups_controller.rb', line 55

def destroy
  @group.destroy

  flash[:notice] = 'Group was successfully destroyed.'
  redirect_to groups_url
end

#editObject

Editing for a group



26
27
# File 'app/controllers/guts/groups_controller.rb', line 26

def edit
end

#indexObject

Displays a list of groups



12
13
14
# File 'app/controllers/guts/groups_controller.rb', line 12

def index
  @groups = Group.all
end

#newObject

Creation of a new group



21
22
23
# File 'app/controllers/guts/groups_controller.rb', line 21

def new
  @group = Group.new
end

#showObject

Shows details about a single group



17
18
# File 'app/controllers/guts/groups_controller.rb', line 17

def show
end

#updateObject

Note:

Redirects to #index if successfull or re-renders #edit if not

Updates a group through patch



44
45
46
47
48
49
50
51
# File 'app/controllers/guts/groups_controller.rb', line 44

def update
  if @group.update(group_params)
    flash[:notice] = 'Group was successfully updated.'
    redirect_to edit_group_path(@group)
  else
    render :edit
  end
end