[英]Rails 4.2.0 - Errno::EACCES (Permission denied @ dir_s_mkdir - /files)
[英]Rails PaperClip Errno::EACCES (Permission denied @ dir_s_mkdir - ~rails
嘗試在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'
在控制器中,我有
class Article < ActiveRecord::Base
has_attached_file :img,
url: "/system/:attachment/:id/:style/:filename",
validates_attachment_content_type :img, content_type: /\Aimage\/.*\Z/
end
如果此信息還不夠,請評論問題可能存在的其他地方,我將很樂意分享更多代碼。
解決了。 問題在於,在虛擬服務器上處理Rails的用戶沒有代表該應用文件夾中的回形針生成文件所需的所有訪問權限。 因此,我可以使用以下終端命令對文件夾進行更大的訪問:
$ sudo chmod -R 775 /RailsAppFolder
嘗試更換
path: "~rails/umbertoputzu/public/system/:attachment/:id/:style/:filename",
同
path: "~/rails/umbertoputzu/public/system/:attachment/:id/:style/:filename",
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.