2022-11-25 15:17:54 +01:00
|
|
|
module Cms
|
|
|
|
class PagesController < CmsController
|
2022-11-25 17:56:46 +01:00
|
|
|
before_action :set_page, only: %i[ show edit update destroy ]
|
2022-11-25 12:21:52 +01:00
|
|
|
|
2022-11-25 15:17:54 +01:00
|
|
|
# GET /cms/pages
|
|
|
|
def index
|
2022-11-25 17:56:46 +01:00
|
|
|
@pages = Cms::Page.all
|
2022-11-25 15:17:54 +01:00
|
|
|
end
|
2022-11-25 12:21:52 +01:00
|
|
|
|
2022-11-25 15:17:54 +01:00
|
|
|
# GET /cms/pages/1
|
|
|
|
def show
|
|
|
|
end
|
2022-11-25 12:21:52 +01:00
|
|
|
|
2022-11-25 15:17:54 +01:00
|
|
|
# GET /cms/pages/new
|
|
|
|
def new
|
2022-11-25 17:56:46 +01:00
|
|
|
@page = Cms::Page.new
|
2022-11-25 15:17:54 +01:00
|
|
|
end
|
2022-11-25 12:21:52 +01:00
|
|
|
|
2022-11-25 15:17:54 +01:00
|
|
|
# GET /cms/pages/1/edit
|
|
|
|
def edit
|
|
|
|
end
|
2022-11-25 12:21:52 +01:00
|
|
|
|
2022-11-25 15:17:54 +01:00
|
|
|
# POST /cms/pages
|
|
|
|
def create
|
2022-11-25 17:56:46 +01:00
|
|
|
@page = Cms::Page.new(page_params)
|
2022-11-25 12:21:52 +01:00
|
|
|
|
2022-11-25 17:56:46 +01:00
|
|
|
if @page.save
|
|
|
|
redirect_to @page, notice: "Page was successfully created."
|
2022-11-25 15:17:54 +01:00
|
|
|
else
|
|
|
|
render :new, status: :unprocessable_entity
|
|
|
|
end
|
2022-11-25 12:21:52 +01:00
|
|
|
end
|
|
|
|
|
2022-11-25 15:17:54 +01:00
|
|
|
# PATCH/PUT /cms/pages/1
|
|
|
|
def update
|
2022-11-25 17:56:46 +01:00
|
|
|
if @page.update(page_params)
|
|
|
|
redirect_to @page, notice: "Page was successfully updated."
|
2022-11-25 15:17:54 +01:00
|
|
|
else
|
|
|
|
render :edit, status: :unprocessable_entity
|
|
|
|
end
|
2022-11-25 12:21:52 +01:00
|
|
|
end
|
|
|
|
|
2022-11-25 15:17:54 +01:00
|
|
|
# DELETE /cms/pages/1
|
|
|
|
def destroy
|
2022-11-25 17:56:46 +01:00
|
|
|
@page.destroy
|
|
|
|
redirect_to page_url, notice: "Page was successfully destroyed."
|
2022-11-25 12:21:52 +01:00
|
|
|
end
|
|
|
|
|
2022-11-25 15:17:54 +01:00
|
|
|
private
|
|
|
|
# Use callbacks to share common setup or constraints between actions.
|
2022-11-25 17:56:46 +01:00
|
|
|
def set_page
|
|
|
|
@page = Cms::Page.find(params[:id])
|
2022-11-25 15:17:54 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
# Only allow a list of trusted parameters through.
|
2022-11-25 17:56:46 +01:00
|
|
|
def page_params
|
|
|
|
params.fetch(:page, {})
|
2022-11-25 15:17:54 +01:00
|
|
|
end
|
|
|
|
end
|
2022-11-25 12:21:52 +01:00
|
|
|
end
|