mirror of
https://github.com/danog/yawarehouse.git
synced 2024-11-26 20:14:49 +01:00
49 lines
785 B
Ruby
49 lines
785 B
Ruby
class SectionsController < ApplicationController
|
|
def index
|
|
@sections = Section.all
|
|
end
|
|
|
|
def new
|
|
@section = Section.new
|
|
end
|
|
|
|
def show
|
|
@section = Section.find(params[:id])
|
|
end
|
|
|
|
def edit
|
|
@section = Section.find(params[:id])
|
|
end
|
|
|
|
def create
|
|
@section = Section.new(section_params)
|
|
if @section.save
|
|
redirect_to sections_path
|
|
else
|
|
render "new"
|
|
end
|
|
end
|
|
|
|
def update
|
|
@section = Section.find(params[:id])
|
|
if @section.update(section_params)
|
|
redirect_to sections_path
|
|
else
|
|
render "edit"
|
|
end
|
|
end
|
|
|
|
def destroy
|
|
@section = Section.find(params[:id])
|
|
@section.destroy
|
|
|
|
redirect_to sections_path
|
|
end
|
|
|
|
private
|
|
|
|
def section_params
|
|
params.require(:section).permit(:description)
|
|
end
|
|
end
|