Ruby on rails 如何在Rails中呈现预压缩的.gz资产?

Ruby on rails 如何在Rails中呈现预压缩的.gz资产?,ruby-on-rails,ruby,static,render,webrick,Ruby On Rails,Ruby,Static,Render,Webrick,我有一个预压缩的.gz文件,我想在视图中渲染它 首先,我的配置被设置为config.service\u static\u files=true,因此我们不需要像nginx这样的东西来为视图服务 基本上,我的问题出现在尝试渲染文件时 render file: '/public/assets/bomb-html-char-X-1G.html.gz' 我得到的错误如下: ActionView::Template::Error (Your template was not saved as valid

我有一个预压缩的
.gz
文件,我想在视图中渲染它

首先,我的配置被设置为
config.service\u static\u files=true
,因此我们不需要像nginx这样的东西来为视图服务

基本上,我的问题出现在尝试渲染文件时

render file: '/public/assets/bomb-html-char-X-1G.html.gz'
我得到的错误如下:

ActionView::Template::Error (Your template was not saved as valid UTF-8. Please either specify UTF-8 as the encoding for your template in your text editor, or mark the template with its encoding by inserting the following as the first line of the template:

# encoding: <name of correct encoding>.

The source of your template was:

��@��Mk�@�s�+�=�mœ�
                       Yw�Z7��q�ݠI$�*�{��C�y|�2����/�d�����,�6�z�ϒ����,OᰎU�|��0�]]��\�N�
�6e�}���2��Pu���z��_�<�:�u����M�w�Cq���}o./߾
��H�X�q���_�}���U¾�<=�c_öy�/VOV���<$����S�T�/�C=�������u;��s
ActionView::Template::Error(您的模板未另存为有效的UTF-8。请在文本编辑器中指定UTF-8作为模板的编码,或通过插入以下内容作为模板的第一行来标记模板及其编码:
#编码:。
模板的源是:
��@��Mk�@�s�+�=�mœ�
Yw�Z7��Q�ݠI$�*�{��C�y|�2.����/�D�����,�6.�Z�ϒ����,OᰎU�|��0�]]��\�N�

�6e�}���2.��聚氨基甲酸酯���Z��_�您是在尝试允许下载.gz文件还是尝试将其作为模板呈现?您应该使用
send_file
而不是
render file
我仍在尝试呈现文件,类似于:该页面没有呈现文件。它只是显示文件中字符数的视觉表示。实际上,如果您查看在文件的提取版本中,您将获得“是”,因此它正在呈现文件。如果要确认这一点,您可以在此处进行检查:
 => #<Encoding:UTF-8>