class HomeController < ApplicationController
  before_filter :load_asciicast

  def show
    @title = "Share Your Terminal With No Fuss"

    if @asciicast
      @asciicast = AsciicastDecorator.new(@asciicast)
    end

    @asciicasts = AsciicastDecorator.decorate_collection(
      Asciicast.order("created_at DESC").limit(9).includes(:user)
    )
  end

  private

  def load_asciicast
    if id = CFG['HOME_CAST_ID']
      @asciicast = Asciicast.find(id)
    else
      @asciicast = Asciicast.order("created_at DESC").first
    end
  end
end

class HomeController < ApplicationController
  def show
    @title = "Share Your Terminal With No Fuss"

    if home_asciicast_id = CFG['HOME_CAST_ID']
      asciicast = Asciicast.find(home_asciicast_id)
    else
      asciicast = Asciicast.order("created_at DESC").first
    end

    if asciicast
      @asciicast = AsciicastDecorator.new(asciicast)
    end

    @asciicasts = AsciicastDecorator.decorate_collection(
      Asciicast.order("created_at DESC").limit(9).includes(:user)
    )
  end
end

--- 
+++ 
@@ -1,19 +1,25 @@
 class HomeController < ApplicationController
+  before_filter :load_asciicast
+
   def show
     @title = "Share Your Terminal With No Fuss"
 
-    if home_asciicast_id = CFG['HOME_CAST_ID']
-      asciicast = Asciicast.find(home_asciicast_id)
-    else
-      asciicast = Asciicast.order("created_at DESC").first
-    end
-
-    if asciicast
-      @asciicast = AsciicastDecorator.new(asciicast)
+    if @asciicast
+      @asciicast = AsciicastDecorator.new(@asciicast)
     end
 
     @asciicasts = AsciicastDecorator.decorate_collection(
       Asciicast.order("created_at DESC").limit(9).includes(:user)
     )
   end
+
+  private
+
+  def load_asciicast
+    if id = CFG['HOME_CAST_ID']
+      @asciicast = Asciicast.find(id)
+    else
+      @asciicast = Asciicast.order("created_at DESC").first
+    end
+  end
 end
Load homepage asciicast in before_filter
