You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to cache my http status response pages, and I use my mountable engine to generate those pages for each of my applications. The problem is that nothing gets cached. I've verified that the controller method is being executed as I actually do get the fully generated HTML response; it's just that the file isn't saved to /public. You'll note below that I attempt to log the public directory inside the page_cache_directory proc but I don't see any logs written either.
%w(401 403 404 410 422 500).each do |code|
get code, to: 'errors#show', as: "error_#{ code }", code: code
end
ErrorsController:
require_dependency 'manager/application_controller'
module Manager
# Raise templated HTTP response pages
class ErrorsController < ApplicationController
skip_before_action :login_required
skip_before_action :find_model
self.page_cache_directory = -> { Rails.logger.debug Rails.root.join('public').inspect; return Rails.root.join('public') }
caches_page :show
def show
render_status params[:code]
end
protected
def render_status(status = 500)
status = status.to_i
respond_to do |format|
format.any(:html, :shtml) do
render "#{ status }.html", status: status
end
end
rescue ActionController::UnknownFormat, ActionView::MissingTemplate
head status: status
end
end
end
I also call caches_page directly in one of the main application's controller and it works. It's just from within the rails engine that it doesn't.
The text was updated successfully, but these errors were encountered:
I want to cache my http status response pages, and I use my mountable engine to generate those pages for each of my applications. The problem is that nothing gets cached. I've verified that the controller method is being executed as I actually do get the fully generated HTML response; it's just that the file isn't saved to
/public
. You'll note below that I attempt to log the public directory inside thepage_cache_directory
proc but I don't see any logs written either.Main app:
config/application.rb:
config.exceptions_app = routes
Engine:
lib/manager/engine.rb: (don't know for sure if this is what I need to require, so I tried both)
Routes:
ErrorsController:
I also call
caches_page
directly in one of the main application's controller and it works. It's just from within the rails engine that it doesn't.The text was updated successfully, but these errors were encountered: