gateway/app/controllers/cms/pages_controller.rb

61 lines
1.2 KiB
Ruby
Raw Normal View History

2022-11-25 15:17:54 +01:00
module Cms
class PagesController < CmsController
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
@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
@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
@page = Cms::Page.new(page_params)
2022-11-25 12:21:52 +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
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
@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.
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.
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