简体   繁体   English

我应该将文件存储在哪里?

[英]where should I store files in rails?

1) I am downloading datafeeds (xml) files from a URL to unzip/import them into the database. 1) 我正在从 URL 下载数据馈送 (xml) 文件,以将它们解压缩/导入到数据库中。 Where should I store them in the rails file structure?我应该将它们存储在 rails 文件结构中的什么位置?

2) How does the rails file structure work, can rails access the entire hosting environment? 2)rails文件结构是如何工作的,rails可以访问整个托管环境吗? I basically mean, if I store my XML feed in /lib/files would I use that path in my models, or the longer full linux path?我的基本意思是,如果我将 XML 提要存储在 /lib/files 中,我会在模型中使用该路径,还是使用更长的完整 linux 路径?

Appreciate any advice!感谢任何建议!

  1. You should probably use the tmp/ folder to store those temporary files您可能应该使用 tmp/ 文件夹来存储这些临时文件
  2. Its a good practice to always use the full path.始终使用完整路径是一个好习惯。 You can get the rails root dir via Rails.root您可以通过 Rails.root 获取 rails 根目录

Rails can access any thing that the user account under which the rails process is running, can access. Rails 可以访问运行 rails 进程的用户帐户可以访问的任何内容。 ie: if you run the rails server process under root (which is not a good idea BTW), the app could access any path that root can access.即:如果您在 root 下运行 rails 服务器进程(顺便说一句,这不是一个好主意),应用程序可以访问 root 可以访问的任何路径。 This might of course be limited by whatever access control mechanisms in place by the OS(ex: SELinux).当然,这可能会受到操作系统(例如:SELinux)的任何访问控制机制的限制。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Ruby on Rails:我应该在哪里存储模块? - Ruby on Rails: where should I store modules? 我应该在哪里存储Rails应用程序的站点站点配置设置? - Where should I store a site sitewide configuration setting for a Rails app? 我应该在Rails应用程序中存储会话代码? - Where should I store session code in a Rails app? 我应该在哪里存储常量数据,然后如何在Rails中引用它? - Where should I store constant data and then how to reference it in Rails? 在Rails中存储XML文件的位置 - Where to store XML files in Rails Rails 4 - 在哪里存储临时文件? - Rails 4 - where to store temporarily files? 我应该在Rails的整个应用程序中使用的计算值存储在哪里? - Where should I store calculated values I use throughout my application in Rails? Rails,CarrierWave在哪里存储文件? - Rails, where does CarrierWave store files? 在 Rails 文件夹结构中,我应该在哪里存储文本文件以将其作为 model 中的字符串调用? - In Rails folder structure, where should I store a text file to call it as a string inside a model? 从我的 Rails 应用程序调用 API 时,我应该将令牌存储在哪里? - Where should I store the token when calling an API from my Rails app?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM