хранение тумана несущей волны

Я просто не могу понять, как это сделать. Мне нужно получить путь S3 без имени файла https://testphotobucket.s3.amazonaws.com/uploads/51237a37ff770df332000007/

а не так https://testphotobucket.s3.amazonaws.com/uploads/51237a37ff770df332000007/tiger.jpg

но я продолжаю получать эту ошибку. неопределенный метод gallery_photo_path' for #<Gallery:0x007f94f4658778> undefined methodgallery_photo_http_url' для #

только как мне получить путь, если я использую туман в качестве хранилища?

Спасибо. ниже мой фрагмент кода.

# models/gallery.rb
class Gallery

  include Mongoid::Document        

  mount_uploader :gallery_photo, PhotoUploader

# uploaders/photo_uploader.rb
class PhotoUploader < CarrierWave::Uploader::Base

  storage :fog

# views/galleries/show.html.erb
<%= image_tag @gallery.gallery_photo_url.to_s %>
path **<%= @gallery.gallery_photo_path.to_s %>**   <--- not working
httppath **<%= @gallery.gallery_photo_http_url.to_s %>** <--- not working

# the error:
undefined method `gallery_photo_path' for #<Gallery:0x007f94f4658778>
undefined method `gallery_photo_http_url' for #<Gallery:0x007f94f46431e8>

person Axil    schedule 21.02.2013    source источник


Ответы (1)


То, о чем вы просите, не встроено в несущую. Вероятно, вам следует поместить это в помощник:

def uri_dirname(uri_string)
  uri = URI.parse(uri_string)
  uri.path = File.dirname(uri.path)
  uri.to_s
end

И тогда, по вашему мнению, вы можете использовать:

uri_dirname(@gallery.gallery_photo.uri)
person Taavo    schedule 28.08.2013