Class: Peoplefinder::GroupsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Peoplefinder::GroupsController
- Defined in:
- app/controllers/peoplefinder/groups_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
POST /groups.
-
#destroy ⇒ Object
DELETE /groups/1.
-
#edit ⇒ Object
GET /groups/1/edit.
-
#index ⇒ Object
GET /groups.
-
#new ⇒ Object
GET /groups/new.
-
#show ⇒ Object
GET /groups/1.
-
#update ⇒ Object
PATCH/PUT /groups/1.
Instance Method Details
#create ⇒ Object
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 |
#destroy ⇒ Object
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 |
#edit ⇒ Object
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 |
#index ⇒ Object
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 |
#new ⇒ Object
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 |
#show ⇒ Object
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 |
#update ⇒ Object
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 |