Rails3:更改临时(tmp)目录的位置

发布于 2024-11-01 19:49:11 字数 139 浏览 5 评论 0原文

我通常在本地 Dropbox 文件夹中进行开发。 tmp 文件夹中的某些文件会被浏览器锁定(并使 Dropbox 保持忙碌),Growl 会引发异常等等。

因此,我正在寻找一个配置设置,将 tmp 文件夹放在 Rails-app 包之外。这可能吗?

I usually develop in my local Dropbox folder. Some files in the tmp-folder get locked by the browsers (and keep Dropbox busy), Growl throws exceptions and so on.

Therefore I am looking for a configuration setting to put the tmp-folder outside the Rails-app bundle. Is that possible?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

空城缀染半城烟沙 2024-11-08 19:49:11

这不是您正在寻找的答案 - 但我可以明确地说,没有配置选项可以更改 Rails 认为 tmp 文件夹所在的位置。该位置被硬编码在 Rails 代码库的许多不同位置。

看起来符号链接同步原始文件,因此您可能会遇到相同的锁定问题。

如果您这样做,那么您可以相反地使用符号链接来解决您的问题,即。在您的保管箱外部创建您的项目,并将除tmp之外的所有内容符号链接到您的保管箱中的文件夹中。

因此,您的 Rails 应用程序可能位于 ~/work/rails_project/<所有 Rails 目录,包括 tmp>,然后您的保管箱中将有一个相应的目录,例如 ~/dropbox /rails_project 然后内部该目录,您将手动创建一堆符号链接,然后删除 tmp 一个,使用 bash 您可以这样做

$ for f in ~/work/rails_project/*; do ln -s $f; done
$ rm tmp

:如果您向应用程序的根目录添加了新文件/目录,则需要记住再次运行该命令。

Not the answer you're looking for - but I can definitively say that there's no configuration option to change where Rails thinks the tmp folder is. The location is hard coded in many different places in the Rails codebase.

Looks like the symlink will sync the original file, so you'll probably have the same locking problems.

If you do, then you can just use the symlinks the other way around to solve your problem, ie. create your project outside your dropbox, and symlink everything other than tmp into a folder in your dropbox.

So you might have your Rails app in ~/work/rails_project/<all the rails dirs including tmp> and then you'll have a corresponding dir in your dropbox, like ~/dropbox/rails_project and then inside that dir you'll manually create a bunch of symlinks and then delete the tmp one, using bash you'd do this:

$ for f in ~/work/rails_project/*; do ln -s $f; done
$ rm tmp

You'd need to remember to run that again if you ever added a new file/directory to the root of your app.

他是夢罘是命 2024-11-08 19:49:11
ENV['TMPDIR'] = Rails.root.join('tmp')
ENV['TMPDIR'] = Rails.root.join('tmp')
女中豪杰 2024-11-08 19:49:11

您无法更改 tmp 目录,但可以配置 tmp 缓存目录。

# config/application.rb
config.cache_store                   = [ :file_store, "/tmp/rails-cache/" ]
config.assets.cache_store            = [ :file_store, "/tmp/rails-cache/assets/#{Rails.env}/" ]

您可以在 configuration.rb 阅读更多信息

you can't change tmp directory, but you can configure tmp cache directory.

# config/application.rb
config.cache_store                   = [ :file_store, "/tmp/rails-cache/" ]
config.assets.cache_store            = [ :file_store, "/tmp/rails-cache/assets/#{Rails.env}/" ]

you can read more at configuration.rb

兔姬 2024-11-08 19:49:11

您可以使用选择性同步在 Dropbox 中排除某个目录的同步:http ://www.dropbox.com/help/175/en

基本上选择 Dropbox 首选项并进入“高级”。然后选择“选择性同步”并查找要从同步中排除的文件夹[如果您必须进入比第一级目录深度更深的位置,还有一个高级视图]

You can exclude a directory from being synced in Dropbox by using Selective Sync: http://www.dropbox.com/help/175/en

Basically select the Dropbox preferences and go in Advanced. Select then Selective Sync and look for the folder that you want to exclude from syncing [there is also an advanced view if you have to go in a deeper than 1st level dir depth]

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文