Class: Peoplefinder::GroupsController

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

Instance Method Summary collapse

Instance Method Details

#createObject

POST /groups



37
38
39
40
41
42
43
44
45
46
47
# File 'app/controllers/peoplefinder/groups_controller.rb', line 37

def create
  @group = collection.new(group_params)

  if @group.save
    notice :group_created, group: @group
    redirect_to @group
  else
    error :create_error
    render :new
  end
end

#destroyObject

DELETE /groups/1



61
62
63
64
65
66
# File 'app/controllers/peoplefinder/groups_controller.rb', line 61

def destroy
  next_page = @group.parent ? @group.parent : groups_url
  @group.destroy
  notice :group_deleted, group: @group
  redirect_to next_page
end

#editObject

GET /groups/1/edit



32
33
34
# File 'app/controllers/peoplefinder/groups_controller.rb', line 32

def edit
  @group.memberships.build if @group.memberships.empty?
end

#indexObject

GET /groups



8
9
10
11
12
13
14
15
# File 'app/controllers/peoplefinder/groups_controller.rb', line 8

def index
  @group = Group.department || Group.first
  if @group
    redirect_to @group
  else
    redirect_to new_group_path
  end
end

#newObject

GET /groups/new



26
27
28
29
# File 'app/controllers/peoplefinder/groups_controller.rb', line 26

def new
  @group = collection.new
  @group.memberships.build person: person_from_person_id
end

#showObject

GET /groups/1



18
19
20
21
22
23
# File 'app/controllers/peoplefinder/groups_controller.rb', line 18

def show
  respond_to do |format|
    format.html { session[:last_group_visited] = @group.id }
    format.js
  end
end

#updateObject

PATCH/PUT /groups/1



50
51
52
53
54
55
56
57
58
# File 'app/controllers/peoplefinder/groups_controller.rb', line 50

def update
  if @group.update(group_params)
    notice :group_updated, group: @group
    redirect_to @group
  else
    error :update_error
    render :edit
  end
end