可调曲别针路径

Adjustable paperclip path

在我的 Rails 项目中,我为 Paperclip gem 设置了此设置,使用数据库扩展名:

 # Image attachment and validations
  has_attached_file :image,
                    :storage => :database,
                    :url => "/:rails_root/public/system/projects/000/000/:id/original/:filename",
                    :path => "/:rails_root/public/system/projects/000/000/:id/original/:filename"

现在,图像得到这条路线:

/C:/Users...

如果我去掉开头的 /,我会得到 images/C:/Users...。知道如何在前面没有任何东西的情况下只获得 rails_root 吗?

我在这里找到了我的解决方案config/initializers/paperclip.rb

    Paperclip::Attachment.default_options.merge!({
  :storage => :database,
  :url => ":rails_root/public",
  :path => ":rails_root/public"
})