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
49
app/controllers/categories_controller.rb
Normal file
49
app/controllers/categories_controller.rb
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
class CategoriesController < ApplicationController
|
||||
allow_unauthenticated_access only: %i[ index show ]
|
||||
before_action :set_category, only: %i[ show edit update destroy ]
|
||||
def index
|
||||
@categories = Category.all
|
||||
end
|
||||
|
||||
def show
|
||||
@clips = Clip.where("category_id = ?", params[:id])
|
||||
end
|
||||
|
||||
def new
|
||||
@category = Category.new
|
||||
end
|
||||
|
||||
def create
|
||||
@category = Category.new(category_params)
|
||||
if @category.save
|
||||
redirect_to @category
|
||||
else
|
||||
render :new, status: :unprocessable_entity
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
end
|
||||
|
||||
def update
|
||||
if @category.update(category_params)
|
||||
redirect_to @category
|
||||
else
|
||||
render :edit, status: :unprocessable_entity
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@category.destroy
|
||||
redirect_to categories_path
|
||||
end
|
||||
|
||||
private
|
||||
def set_category
|
||||
@category = Category.find(params[:id])
|
||||
end
|
||||
|
||||
def category_params
|
||||
params.expect(category: [ :name ])
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue