Reputation: 8467
I have a basic Rails application layout, with
<%= stylesheet_link_tag 'application', media: 'all' %>
<%= javascript_include_tag 'application' %>
Using nginx, I'm asking for an optional client certificate:
ssl on;
ssl_verify_client optional;
When a client connects with a bad certificate (expired, not yet valid, or not trusted, for example) nginx responds weakly with a generic page reading, "The SSL certificate error".
To provide a reasonable user experience, I tell nginx:
error_page 495 /actual_useful_information.html;
But now I lose my stylesheets and javascripts, for when the browser loads the page and follows the links of the Rails layout, the certificate is still bad and the stylesheets are not forthcoming.
Is there a solution to serve the styled page making use of the layout? Is there a way to inline the assets pipeline (for just this one case)?
Having the javascript in there would be nice too, but at least, how about the styles.
Upvotes: 0
Views: 57
Reputation: 8467
I found my own answer:
<% if @inline_assets %>
<script><%== File.read("public#{javascript_path('application')}") %></script>
<style><%== File.read("public#{stylesheet_path('application')}") %></style>
<% else %>
<%= stylesheet_link_tag 'application', media: 'all' %>
<%= javascript_include_tag 'application' %>
<% end %>
Upvotes: 1