Class: MissionControl::Servers::PublicProjectsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/mission_control/servers/public_projects_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

POST /public_projects



29
30
31
32
33
34
35
36
37
# File 'app/controllers/mission_control/servers/public_projects_controller.rb', line 29

def create
  @public_project = @project.public_projects.new(public_project_params)

  if @public_project.save
    redirect_to project_public_projects_path(@project), notice: "Public project was successfully created."
  else
    render :new, status: :unprocessable_entity
  end
end

#destroyObject

DELETE /public_projects/1



40
41
42
43
44
# File 'app/controllers/mission_control/servers/public_projects_controller.rb', line 40

def destroy
  @public_project = @project.public_projects.find(params[:id])
  @public_project.destroy!
  redirect_to project_public_projects_path(@project), notice: "Public project was successfully destroyed.", status: :see_other
end

#indexObject

GET /public_projects



6
7
8
# File 'app/controllers/mission_control/servers/public_projects_controller.rb', line 6

def index
  @public_projects = @project.public_projects.all
end

#newObject

GET /public_projects/new



24
25
26
# File 'app/controllers/mission_control/servers/public_projects_controller.rb', line 24

def new
  @public_project = @project.public_projects.new
end

#showObject

GET /public_projects/1



11
12
13
14
15
16
17
18
19
20
21
# File 'app/controllers/mission_control/servers/public_projects_controller.rb', line 11

def show
  @project.public_projects.find_by!(token: params[:id])

  hostnames = @project.services.pluck(:hostname).uniq
  @service_settings = @project.service_settings.where(hostname: hostnames)
  @services = if params[:hostname]
    @project.services.where(hostname: params[:hostname]).group_by(&:hostname)
  else
    @project.services.group_by(&:hostname)
  end
end