Class: SimpleTeams::TeamsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/simple_teams/teams_controller.rb,
app/controllers/simple_teams/admin/teams_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

POST /teams



24
25
26
27
28
29
30
31
32
# File 'app/controllers/simple_teams/admin/teams_controller.rb', line 24

def create
  @team = Team.new(team_params)

  if @team.save
    redirect_to @team, notice: "Team was successfully created."
  else
    render :new, status: :unprocessable_entity
  end
end

#destroyObject

DELETE /teams/1



44
45
46
47
# File 'app/controllers/simple_teams/admin/teams_controller.rb', line 44

def destroy
  @team.destroy
  redirect_to teams_url, notice: "Team was successfully destroyed.", status: :see_other
end

#editObject

GET /teams/1/edit



20
21
# File 'app/controllers/simple_teams/admin/teams_controller.rb', line 20

def edit
end

#indexObject

GET /teams



6
7
8
# File 'app/controllers/simple_teams/admin/teams_controller.rb', line 6

def index
  @teams = Team.all
end

#newObject

GET /teams/new



15
16
17
# File 'app/controllers/simple_teams/admin/teams_controller.rb', line 15

def new
  @team = Team.new
end

#showObject

GET /teams/1



11
12
13
14
15
16
# File 'app/controllers/simple_teams/admin/teams_controller.rb', line 11

def show
  authorize! :read, @team
  @memberships = @team.memberships.joins(:member).order(:first_name)
  @invitations = @team.invitations.initial.order(:email)
  @memberships_and_invitations = @memberships.to_a + @invitations.to_a
end

#updateObject

PATCH/PUT /teams/1



35
36
37
38
39
40
41
# File 'app/controllers/simple_teams/admin/teams_controller.rb', line 35

def update
  if @team.update(team_params)
    redirect_to @team, notice: "Team was successfully updated.", status: :see_other
  else
    render :edit, status: :unprocessable_entity
  end
end