Rails缓存权限错误

Rails Cache Permission Error

我有一个 Rails 应用程序(一个 Spree Commerce 商店)运行在 Digital Ocean 上并通过 Cloud 66 部署。

我想通过 SSH 连接到我的服务器,运行 一个 rails 控制台,并调整一些 Spree 配置设置。当我尝试这样做时,出现权限错误:

Errno::EACCES: Permission denied @ dir_s_mkdir - /var/deploy/my-app/web_head/releases/20150220220517/tmp/cache/29B

根据 Spree Developer Guide's page on preferences,这是因为首选项被缓存到内存中以提高性能。问题(我认为)是我的用户没有对 tmp/cache 目录的写入权限,而 运行 正在 rails 控制台的是我的用户。

如果我 ls -l 在 $STACK_PATH/tmp/cache 目录上,我得到以下内容:

> lrwxrwxrwx 1 nginx nginx 43 Feb 20 22:05
> tmp/cache ->
> /var/deploy/my-app/web_head/shared/cache

我想我需要像 nginx 用户一样授予我的用户对该目录的写入权限。我尝试将自己添加到 nginx 用户组,但似乎没有任何效果。我该怎么做才能防止出现此权限错误?

好的,我根据 Cloud 66 支持论坛上的 this question and answer 弄明白了。

我将缓存文件夹的组所有者更改为 app_writers,我的用户所属的组。 Cloud 66 的方法是使用部署挂钩。这是对我有用的 yml 文件:

production:
    after_rails:
        command: chown nginx:app_writers /var/deploy/my-app/web_head/current/tmp/cache && chmod -R 775 /var/deploy/my-app/web_head/current/tmp/cache
        target: rails
        run_on: all_servers
        sudo: true