0

I just cant figure out how to do this. I need to get the S3 path without the filename https://testphotobucket.s3.amazonaws.com/uploads/51237a37ff770df332000007/

and not like this https://testphotobucket.s3.amazonaws.com/uploads/51237a37ff770df332000007/tiger.jpg

but i keep getting this error. undefined method gallery_photo_path' for #<Gallery:0x007f94f4658778> undefined methodgallery_photo_http_url' for #

just how do i get the path if im using fog as the storage ?

Thanks. below is my code snippet.

# 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>
ole
  • 5,166
  • 5
  • 29
  • 57
Axil
  • 3,606
  • 10
  • 62
  • 136

1 Answers1

0

What you're asking for isn't built into carrierwave. You should probably put this in a helper:

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

And then in your view you can use:

uri_dirname(@gallery.gallery_photo.uri)
Taavo
  • 2,406
  • 1
  • 17
  • 17