Class: Guts::GroupsController

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

Overview

Groups controller

Instance Method Summary collapse

Methods included from MultisiteConcern

#current_site, #with_current_site

Methods included from SessionsHelper

#current_user, #log_in, #log_out, #logged_in?

Instance Method Details

#createObject

Note:

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

Creates a group through post



28
29
30
31
32
33
34
35
36
37
# File 'app/controllers/guts/groups_controller.rb', line 28

def create
  @group = Group.new group_params

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

#destroyObject

Note:

Redirects to #index on success

Destroys a group



52
53
54
55
56
57
# File 'app/controllers/guts/groups_controller.rb', line 52

def destroy
  @group.destroy
  
  flash[:notice] = 'Group was successfully destroyed.'
  redirect_to groups_url
end

#editObject

Editing for a group



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

def edit
end

#indexObject

Displays a list of groups



9
10
11
# File 'app/controllers/guts/groups_controller.rb', line 9

def index
  @groups = Group.all
end

#newObject

Creation of a new group



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

def new
  @group = Group.new
end

#showObject

Shows details about a single group



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

def show
end

#updateObject

Note:

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

Updates a group through patch



41
42
43
44
45
46
47
48
# File 'app/controllers/guts/groups_controller.rb', line 41

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