summaryrefslogtreecommitdiff
path: root/app/controllers/environments_controller.rb
blob: 8a82c9b4442f695b2ec8b5366fc57a9c51f5f6bd (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
class EnvironmentsController < ApplicationController
  def index
    @environments = Environment.where(id: params[:ids])
  end

  def show
    @environment = Environment.find(params[:id])
  end

  def create
    service = Service.find(params[:environment][:service_id])
    @environment = service.environments.create!(environment_params)
  end

  def destroy
    Environment.find(params[:id]).destroy
    render json: {}
  end

  private

  def environment_params
    params.require(:environment).permit(:name)
  end
end