Class: MissionControl::Servers::ProjectsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- MissionControl::Servers::ProjectsController
- Defined in:
- app/controllers/mission_control/servers/projects_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
POST /projects.
-
#destroy ⇒ Object
DELETE /projects/1.
-
#edit ⇒ Object
GET /projects/1/edit.
-
#index ⇒ Object
GET /projects.
-
#new ⇒ Object
GET /projects/new.
-
#show ⇒ Object
GET /projects/1.
-
#update ⇒ Object
PATCH/PUT /projects/1.
Instance Method Details
#create ⇒ Object
POST /projects
32 33 34 35 36 37 38 39 40 |
# File 'app/controllers/mission_control/servers/projects_controller.rb', line 32 def create @project = Project.new(project_params) if @project.save redirect_to @project, notice: "Project was successfully created." else render :new, status: :unprocessable_entity end end |
#destroy ⇒ Object
DELETE /projects/1
52 53 54 55 56 57 58 59 60 |
# File 'app/controllers/mission_control/servers/projects_controller.rb', line 52 def destroy if params[:hostname] @project.services.where(hostname: params[:hostname]).delete_all redirect_to project_dashboards_project_table_path(@project.token), notice: "Service was successfully destroyed.", status: :see_other else @project.destroy! redirect_to projects_url, notice: "Project was successfully destroyed.", status: :see_other end end |
#edit ⇒ Object
GET /projects/1/edit
28 29 |
# File 'app/controllers/mission_control/servers/projects_controller.rb', line 28 def edit end |
#index ⇒ Object
GET /projects
7 8 9 |
# File 'app/controllers/mission_control/servers/projects_controller.rb', line 7 def index @projects = Project.all end |
#new ⇒ Object
GET /projects/new
23 24 25 |
# File 'app/controllers/mission_control/servers/projects_controller.rb', line 23 def new @project = Project.new end |
#show ⇒ Object
GET /projects/1
12 13 14 15 16 17 18 19 20 |
# File 'app/controllers/mission_control/servers/projects_controller.rb', line 12 def show 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 |
#update ⇒ Object
PATCH/PUT /projects/1
43 44 45 46 47 48 49 |
# File 'app/controllers/mission_control/servers/projects_controller.rb', line 43 def update if @project.update(project_params) redirect_to @project, notice: "Project was successfully updated.", status: :see_other else render :edit, status: :unprocessable_entity end end |