blob: c6a9a0a403acc20fba4710f49b5cf02f56c764fe (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
class Projects::EnvironmentsController < Projects::ApplicationController
layout 'project'
before_action :authorize_read_environment!
before_action :environment, only: [:show, :destroy]
def index
@environments = project.environments
end
def show
@deployments = environment.deployments.order(id: :desc).page(params[:page]).per(30)
end
def new
@environment = project.environments.new
end
def create
@environment = project.environments.create(create_params)
unless @environment.persisted?
render 'new'
return
end
redirect_to namespace_project_environment_path(project.namespace, project, @environment)
end
def destroy
if @environment.destroy
redirect_to namespace_project_environments_path(project.namespace, project), notice: 'Environment was successfully removed.'
else
redirect_to namespace_project_environments_path(project.namespace, project), alert: 'Failed to remove environment.'
end
end
private
def create_params
params.require(:environment).permit(:name)
end
def environment
@environment ||= project.environments.find(params[:id].to_s)
@environment || render_404
end
end
|