在Rails中存储静态资产(文件)的最佳位置是什么(pdf表单,xls文件等) [英] What is the best place to store static assets (files) in Rails ( pdf forms, xls files, etc)

查看:100
本文介绍了在Rails中存储静态资产(文件)的最佳位置是什么(pdf表单,xls文件等)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一堆静态资产(不是jpg,css和& js)-而是我需要提供给用户的pdf表格,xls之类的文件.他们很少改变.在我以前将它们存储在公用文件夹中之前,但是随着Rails 3.1中资产管道的引入,现在最好的存储文件的地方是什么?

I have a bunch of static assets ( not jpg, css, & js) - rather files like pdf forms, xls that I need to serve to users. They rarely change. Before I used to store them in public folder, but with the introduction of the assets pipeline in rails 3.1 what is the best place to store files like that now now?

推荐答案

实际上,我只是通过在app/assets/files中创建一个文件夹并将我的xls文件粘贴在其中的方法进行了测试,然后通过rake asset:precompile任务将其拾起.

Actually I just tested it by creating a folder in app/assets/files and sticking my xls files in there, and rake assets:precompile task just picked it up.

此外,还需要为Rails< 3.1:

Also this needs to be added for Rails < 3.1:

    # Enable the asset pipeline
config.assets.enabled = true
config.assets.paths << "#{Rails.root}/app/assets/files"

这篇关于在Rails中存储静态资产(文件)的最佳位置是什么(pdf表单,xls文件等)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆