docbrown/app/controllers/internal/pages_controller.rb
Ben Halpern 5891b2ea58
Add application "page" model (#2657)
* Generate page model

* Add page model

* Conditionally modify html rendering
2019-05-02 18:24:06 -04:00

42 lines
845 B
Ruby

class Internal::PagesController < Internal::ApplicationController
layout "internal"
def index
@pages = Page.all
end
def new
@page = Page.new
end
def edit
@page = Page.find(params[:id])
end
def update
@page = Page.find(params[:id])
@page.update!(page_params)
redirect_to "/internal/pages"
end
def create
@page = Page.new(page_params)
@page.save!
redirect_to "/internal/pages"
end
def destroy
@page = Page.find(params[:id])
@page.destroy
redirect_to "/internal/pages"
end
def page_params
params.require(:page).permit(:title,
:slug,
:body_markdown,
:body_html,
:description,
:template)
end
end