Skip to content

Instantly share code, notes, and snippets.

@chewmanfoo
Created December 14, 2017 15:15
Show Gist options
  • Save chewmanfoo/d4c90606c0659d647a0c94bf8f1877b9 to your computer and use it in GitHub Desktop.
Save chewmanfoo/d4c90606c0659d647a0c94bf8f1877b9 to your computer and use it in GitHub Desktop.
CfTemplatesController
# app/controllers/cf_deployments_controller.rb
class CfDeploymentsController < ApplicationController
before_action :set_cf_template
before_action :set_cf_template_cf_deployment, only: [:show, :update, :destroy]
# GET /cf_templates/:cf_template_id/cf_deployments
def index
json_response(@cf_template.cf_deployments)
end
# GET /cf_templates/:cf_template_id/cf_deployments/:id
def show
json_response(@cf_deployment)
end
# POST /cf_templates/:cf_template_id/cf_deployments
def create
#Rails.logger.info "all params: #{cf_deployment_params}"
@cf_template.cf_deployments.create!(cf_deployment_params)
# start CF Deployment
json_response(@cf_template, :created)
end
# PUT /cf_templates/:cf_template_id/cf_deployments/:id
def update
@cf_deployment.update(cf_deployment_params)
head :no_content
end
# DELETE /cf_templates/:cf_template_id/cf_deployments/:id
def destroy
@cf_deployment.destroy
head :no_content
end
private
def cf_deployment_params
params.permit(:env, :account, :delay, :deploy_at, :cf_template_id, :dry_run, cf_deployment:[:env, :account])
end
def set_cf_template
@cf_template = CfTemplate.find(params[:cf_template_id])
end
def set_cf_template_cf_deployment
@cf_deployment = @cf_template.cf_deployments.find_by!(id: params[:id]) if @cf_template
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment