Tapes are now Clips, also they have categories
This commit is contained in:
parent
86c489be72
commit
c8732b6332
41 changed files with 347 additions and 148 deletions
48
app/controllers/clips_controller.rb
Normal file
48
app/controllers/clips_controller.rb
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
class ClipsController < ApplicationController
|
||||
allow_unauthenticated_access only: %i[ index show ]
|
||||
before_action :set_clip, only: %i[ show edit update destroy ]
|
||||
def index
|
||||
@clips = Clip.all
|
||||
end
|
||||
|
||||
def show
|
||||
end
|
||||
|
||||
def new
|
||||
@clip = Clip.new
|
||||
end
|
||||
|
||||
def create
|
||||
@clip = Clip.new(clip_params)
|
||||
if @clip.save
|
||||
redirect_to @clip
|
||||
else
|
||||
render :new, status: :unprocessable_entity
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
end
|
||||
|
||||
def update
|
||||
if @clip.update(clip_params)
|
||||
redirect_to @clip
|
||||
else
|
||||
render :edit, status: :unprocessable_entity
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@clip.destroy
|
||||
redirect_to clips_path
|
||||
end
|
||||
|
||||
private
|
||||
def set_clip
|
||||
@clip = Clip.find(params[:id])
|
||||
end
|
||||
|
||||
def clip_params
|
||||
params.expect(clip: [ :title, :video, :category_id ])
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue