now this is what i call an app
This commit is contained in:
commit
8063246b68
97 changed files with 1989 additions and 0 deletions
48
app/controllers/tapes_controller.rb
Normal file
48
app/controllers/tapes_controller.rb
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
class TapesController < ApplicationController
|
||||
allow_unauthenticated_access only: %i[ index show ]
|
||||
before_action :set_tape, only: %i[ show edit update destroy ]
|
||||
def index
|
||||
@tapes = Tape.all
|
||||
end
|
||||
|
||||
def show
|
||||
end
|
||||
|
||||
def new
|
||||
@tape = Tape.new
|
||||
end
|
||||
|
||||
def create
|
||||
@tape = Tape.new(tape_params)
|
||||
if @tape.save
|
||||
redirect_to @tape
|
||||
else
|
||||
render :new, status: :unprocessable_entity
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
end
|
||||
|
||||
def update
|
||||
if @tape.update(tape_params)
|
||||
redirect_to @tape
|
||||
else
|
||||
render :edit, status: :unprocessable_entity
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@tape.destroy
|
||||
redirect_to tapes_path
|
||||
end
|
||||
|
||||
private
|
||||
def set_tape
|
||||
@tape = Tape.find(params[:id])
|
||||
end
|
||||
|
||||
def tape_params
|
||||
params.expect(tape: [ :title, :video ])
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue