]> cat aescling's git repositories - mastodon.git/commitdiff
Override current_user when generating static pages
authorThibaut Girka <thib@sitedethib.com>
Tue, 18 Dec 2018 22:31:34 +0000 (23:31 +0100)
committerThibG <thib@sitedethib.com>
Wed, 19 Dec 2018 19:49:58 +0000 (20:49 +0100)
lib/tasks/assets.rake

index b642510a1625766c899b2e852f6573b66ac4bec7..5931aae61894239bb294319ccb62ad94b324c364 100644 (file)
@@ -1,13 +1,19 @@
 # frozen_string_literal: true
 
-def render_static_page(action, dest:, **opts)
-  html = ApplicationController.render(action, opts)
-  File.write(dest, html)
-end
-
 namespace :assets do
   desc 'Generate static pages'
   task generate_static_pages: :environment do
+    class StaticApplicationController < ApplicationController
+      def current_user
+        nil
+      end
+    end
+
+    def render_static_page(action, dest:, **opts)
+      html = StaticApplicationController.render(action, opts)
+      File.write(dest, html)
+    end
+
     render_static_page 'errors/500', layout: 'error', dest: Rails.root.join('public', 'assets', '500.html')
   end
 end