diff --git a/spec/dummy/app/controllers/pages_controller.rb b/spec/dummy/app/controllers/pages_controller.rb index 704f561..3d15192 100644 --- a/spec/dummy/app/controllers/pages_controller.rb +++ b/spec/dummy/app/controllers/pages_controller.rb @@ -4,12 +4,16 @@ class PagesController < ApplicationController helper Katalyst::Content::FrontendHelper def show - render locals: { page: } + render locals: { page:, version: page.published_version } + end + + def preview + render :show, locals: { page:, version: page.draft_version } end private def page - @page ||= Page.find_by!(slug: params[:slug]) + @page ||= Page.find_by!(slug: params[:slug] || params[:page_slug]) end end diff --git a/spec/dummy/app/views/pages/show.html.erb b/spec/dummy/app/views/pages/show.html.erb index a01cf29..5a13b25 100644 --- a/spec/dummy/app/views/pages/show.html.erb +++ b/spec/dummy/app/views/pages/show.html.erb @@ -2,4 +2,4 @@

<%= page.title %>

-<%= render_content page.published_version %> +<%= render_content version %> diff --git a/spec/dummy/config/routes.rb b/spec/dummy/config/routes.rb index 526a249..d876276 100644 --- a/spec/dummy/config/routes.rb +++ b/spec/dummy/config/routes.rb @@ -7,7 +7,9 @@ resources :pages end - resources :pages, param: :slug, only: :show, path: "" + resources :pages, param: :slug, only: :show, path: "" do + get "preview" + end resolve("Page") { |page| page_path(page.slug) }