From 58f5890bb1cca659e9c8ef235786bc80ccb732e6 Mon Sep 17 00:00:00 2001 From: Tim Glen Date: Fri, 9 May 2014 14:07:07 -0400 Subject: [PATCH] Include contents (to speed things up a bit) --- app/controllers/smithy/pages_controller.rb | 6 +++--- lib/smithy/liquid/rendering.rb | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/controllers/smithy/pages_controller.rb b/app/controllers/smithy/pages_controller.rb index fbe43dd..2cfe3dc 100644 --- a/app/controllers/smithy/pages_controller.rb +++ b/app/controllers/smithy/pages_controller.rb @@ -72,16 +72,16 @@ def initialize_page end def load_page - @page = Page.find(params[:id]) + @page = Page.includes(:contents).find(params[:id]) @root = @page if Page.root == @page set_publish end def load_page_from_path if smithy_current_user - @page = Page.friendly.find(page_path) + @page = Page.includes(:contents).friendly.find(page_path) else - @page = Page.published.friendly.find(page_path) + @page = Page.includes(:contents).published.friendly.find(page_path) end redirect_to @page.external_link and return false if @page.external_link? end diff --git a/lib/smithy/liquid/rendering.rb b/lib/smithy/liquid/rendering.rb index 77e2392..42aef7d 100644 --- a/lib/smithy/liquid/rendering.rb +++ b/lib/smithy/liquid/rendering.rb @@ -6,10 +6,10 @@ module Rendering def render_smithy_page if smithy_current_user - output = @page.template.liquid_template.render(liquid_context) + output = @page.render(liquid_context) else output = Rails.cache.fetch("#{@page.cache_key}-render_smithy_page") do - @page.template.liquid_template.render(liquid_context) + @page.render(liquid_context) end end render :text => output, :layout => false @@ -21,7 +21,7 @@ def render_as_smithy_page(template_name) end def liquid_context - ::Liquid::Context.new({}, smithy_default_assigns, smithy_default_registers, false) + ::Liquid::Context.new({}, smithy_default_assigns, smithy_default_registers, !Rails.env.production?) end def smithy_default_assigns