简体   繁体   English

Rails PaperClip Errno :: EACCES(权限被拒绝@ dir_s_mkdir-〜rails

[英]Rails PaperClip Errno::EACCES (Permission denied @ dir_s_mkdir - ~rails

I'm getting this error in Unicorn.log when trying to attach files with paper clip on my ubuntu virtual server app: 尝试在ubuntu虚拟服务器应用程序上附加带有回形针的文件时,我在Unicorn.log中收到此错误:

Completed 500 Internal Server Error in 312ms (ActiveRecord: 10.1ms)

Errno::EACCES (Permission denied @ dir_s_mkdir - ~rails):
  app/controllers/articles_controller.rb:30:in `block in create'
  app/controllers/articles_controller.rb:29:in `create'

In the controller I have 在控制器中,我有

class Article < ActiveRecord::Base
    has_attached_file :img,
    url: "/system/:attachment/:id/:style/:filename",
    validates_attachment_content_type :img, content_type: /\Aimage\/.*\Z/
end

If this info is not enough please comment where else the issue could reside, and I'll happily share more code. 如果此信息还不够,请评论问题可能存在的其他地方,我将很乐意分享更多代码。

Solved it. 解决了。 The problem was that the user that handles Rails on the virtual server didn't have all the access needed to generate files on behalf of paperclip in the app's folder. 问题在于,在虚拟服务器上处理Rails的用户没有代表该应用文件夹中的回形针生成文件所需的所有访问权限。 So I gave larger access to the folder using this terminal command: 因此,我可以使用以下终端命令对文件夹进行更大的访问:

$ sudo chmod -R 775 /RailsAppFolder

Try to replace 尝试更换

path: "~rails/umbertoputzu/public/system/:attachment/:id/:style/:filename",

with

path: "~/rails/umbertoputzu/public/system/:attachment/:id/:style/:filename",

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM