Class: Barbeque::AppsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/barbeque/apps_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



18
19
20
21
22
23
24
25
26
# File 'app/controllers/barbeque/apps_controller.rb', line 18

def create
  @app = Barbeque::App.new(params.require(:app).permit(:name, :docker_image, :description))

  if @app.save
    redirect_to @app, notice: 'App was successfully created.'
  else
    render :new
  end
end

#destroyObject



38
39
40
41
42
# File 'app/controllers/barbeque/apps_controller.rb', line 38

def destroy
  @app = Barbeque::App.find(params[:id])
  @app.destroy
  redirect_to root_path, notice: 'App was successfully destroyed.'
end

#editObject



14
15
16
# File 'app/controllers/barbeque/apps_controller.rb', line 14

def edit
  @app = Barbeque::App.find(params[:id])
end

#indexObject



2
3
4
# File 'app/controllers/barbeque/apps_controller.rb', line 2

def index
  @apps = Barbeque::App.all
end

#newObject



10
11
12
# File 'app/controllers/barbeque/apps_controller.rb', line 10

def new
  @app = Barbeque::App.new
end

#showObject



6
7
8
# File 'app/controllers/barbeque/apps_controller.rb', line 6

def show
  @app = Barbeque::App.find(params[:id])
end

#updateObject



28
29
30
31
32
33
34
35
36
# File 'app/controllers/barbeque/apps_controller.rb', line 28

def update
  @app = Barbeque::App.find(params[:id])
  # Name can't be changed after it's created.
  if @app.update(params.require(:app).permit(:docker_image, :description))
    redirect_to @app, notice: 'App was successfully updated.'
  else
    render :edit
  end
end