如何在回形针中使用原始图像网址

Dip*_*hal 8 ruby-on-rails paperclip ruby-on-rails-3

由paperclip上传的图像的原始路径是什么.

has_attached_file :attachment,
  :url  =>           ":rails_root/public/photos/images/:id/:style/:basename.:extension",
  :default =>        ":rails_root/public/images/no-image-available.png",
  :styles =>          style_options,
  :default_style =>   :gallery
Run Code Online (Sandbox Code Playgroud)

和style_options是

  style_options = {  :thumbnail => {:geometry => '100x100'},
                     :profile_gallery =>  {:geometry => '184x247'}
                  }
Run Code Online (Sandbox Code Playgroud)

在我的公共文件夹中创建3个文件夹,同时一个图像上传1.缩略图,2.profile_gallary 3.原始.

在我的视图文件中,我打电话

<%= photo.thumbnail_url %>
Run Code Online (Sandbox Code Playgroud)

我的问题是我想使用上传图片的原始路径.我不想将thumnail用于任何特定网址.我怎样才能使用原始路径.

谢谢你的进步

ror*_*rra 10

<%= photo.attachment.url(:original) %>
Run Code Online (Sandbox Code Playgroud)

这将为您提供原始文件的路径,如果需要,您还可以获取其他样式:

<%= photo.attachment.url(:thumbnail) %>
<%= photo.attachment.url(:profile_gallery) %>
Run Code Online (Sandbox Code Playgroud)