在我的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吗?
答案 0 :(得分:0)
我在config/initializers/paperclip.rb
Paperclip::Attachment.default_options.merge!({
:storage => :database,
:url => ":rails_root/public",
:path => ":rails_root/public"
})