可调节的回形针路径

时间:2017-01-27 09:02:32

标签: ruby database ruby-on-rails-4 paperclip

在我的on 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吗?

1 个答案:

答案 0 :(得分:0)

我在config/initializers/paperclip.rb

找到了我的解决方案
    Paperclip::Attachment.default_options.merge!({
  :storage => :database,
  :url => ":rails_root/public",
  :path => ":rails_root/public"
})