2013-02-21 2 views
0

나는 이것을 수행하는 방법을 알지 못한다. 나는 파일 이름없이이 https://testphotobucket.s3.amazonaws.com/uploads/51237a37ff770df332000007/tiger.jpg반송파 안개 저장

같은 https://testphotobucket.s3.amazonaws.com/uploads/51237a37ff770df332000007/

하지를 S3 경로를 얻을 필요하지만 난이 오류가 점점 계속. 정의되지 않은 방법 gallery_photo_path' for #<Gallery:0x007f94f4658778> undefined method gallery_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> 

답변

0

당신이 요구하는 것은 반송파에 내장되어 있지 않습니다. 다음보기에서 사용할 수있는

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)