require_dependency "jobshop/application_controller" module Jobshop class PagesController < ApplicationController layout :layout_for_page def show args = valid_page? ? [ template: page ] : [ file: "public/404.html", status: :not_found ] render(*args) end private def valid_page? lookup_context.template_exists?(page) end def page "jobshop/pages/#{params[:page]}" end def layout_for_page { index: "jobshop/unauthenticated" }.fetch(params[:page].to_sym) end end end