Class: GraphStarter::GroupsController

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

Instance Method Summary collapse

Instance Method Details

#createObject

POST /groups POST /groups.json



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

def create
  @group = Group.new(group_params)

  respond_to do |format|
    if @group.save
      format.html { redirect_to @group, notice: 'Group was successfully created.' }
      format.json { render :show, status: :created, location: @group }
    else
      format.html { render :new }
      format.json { render json: @group.errors, status: :unprocessable_entity }
    end
  end
end

#destroyObject

DELETE /groups/1 DELETE /groups/1.json



59
60
61
62
63
64
65
# File 'app/controllers/graph_starter/groups_controller.rb', line 59

def destroy
  @group.destroy
  respond_to do |format|
    format.html { redirect_to groups_url, notice: 'Group was successfully destroyed.' }
    format.json { head :no_content }
  end
end

#editObject

GET /groups/1/edit



24
25
# File 'app/controllers/graph_starter/groups_controller.rb', line 24

def edit
end

#indexObject

GET /groups GET /groups.json



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

def index
  @groups = Group.roots
end

#newObject

GET /groups/new



19
20
21
# File 'app/controllers/graph_starter/groups_controller.rb', line 19

def new
  @group = Group.new
end

#showObject

GET /groups/1 GET /groups/1.json



15
16
# File 'app/controllers/graph_starter/groups_controller.rb', line 15

def show
end

#updateObject

PATCH/PUT /groups/1 PATCH/PUT /groups/1.json



45
46
47
48
49
50
51
52
53
54
55
# File 'app/controllers/graph_starter/groups_controller.rb', line 45

def update
  respond_to do |format|
    if @group.update(group_params)
      format.html { redirect_to @group, notice: 'Group was successfully updated.' }
      format.json { render :show, status: :ok, location: @group }
    else
      format.html { render :edit }
      format.json { render json: @group.errors, status: :unprocessable_entity }
    end
  end
end

#users_to_addObject



67
68
69
# File 'app/controllers/graph_starter/groups_controller.rb', line 67

def users_to_add
  render json: @group.addable_users
end