docbrown/app/controllers/internal/pages_controller.rb
rhymes ff929fcf14 Some small performance improvements (#2876)
* Improve a few idioms with their faster counterparts

* Remove unused routes and some dead code

* Add the option to use bullet in testing mode and move rack host redirect

* Go back to the classic fetch to make mocking work

* Reorder gems and fix code climate issue
2019-05-20 18:53:31 -04:00

40 lines
720 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
private
def page_params
allowed_params = %i[title slug body_markdown body_html description template]
params.require(:page).permit(allowed_params)
end
end