【问题标题】:Paperclip Errno::EACCES (Permission denied - /system)回形针 Errno::EACCES(权限被拒绝 - /system)
【发布时间】:2012-08-08 12:06:57
【问题描述】:

我的生产环境是:ruby 1.9.2-p320,rails 3.2.7,回形针3.1.4,mysql,Ubuntu 8.10 x86 64bit。

当我尝试使用回形针上传文件时出现 Errno:EACCES Permission denied /system 错误。不用说在本地不会发生这种情况。 我检查了公共目录权限,它是 775,公共/系统权限是 777 以及它的所有内部目录。 tmp 目录权限也是:775。 此外,用于部署应用程序的用户是 www-data:root

模型的附件是这样设置的:

has_attached_file :fichier,
        :path => "/system/:attachment/:id/:style/:filename",
        :url => "/system/:attachment/:id/:style/:filename"

我不知道为什么会出现此错误。有人有想法吗?

谢谢

【问题讨论】:

    标签: ruby-on-rails paperclip ruby-on-rails-3.2


    【解决方案1】:

    您的代码不会尝试将上传的文件保存在:

    /path/to/app/public/system/:attachment/:id/:style/:filename
    

    但在:

    /system/:attachment/:id/:style/:filename
    

    试试这个:

    has_attached_file :fichier,
        :path => ":rails_root/public/system/:attachment/:id/:style/:filename",
        :url => "/system/:attachment/:id/:style/:filename"
    

    【讨论】:

    • 是的,你太棒了!在我得到这个之前,我一直在搞乱 chmod 的危险
    猜你喜欢
    • 2011-12-28
    • 2015-07-20
    • 2016-03-14
    • 2014-01-24
    • 2019-02-13
    • 1970-01-01
    • 2016-05-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多