2011-05-11 3 views
0

Carrierwave에서 작동하는 앱이 있습니다. 나는 저장된 이미지의 URL에 대한 경로를 제공 할 @ product.image.url과 같은 것을 할 수있다.Carrierwave가 XML보기에서 파일 경로를 표시하지 않습니다. 정상입니까?

그러나 제품 # show (예 : http://localhost:3000/products/1.xml)를 탐색하면 이미지를 제외한 모든 정보가 올바르게 표시됩니다. 콘솔에서

는 product.image.url @ 반환

"https://bucket_name.s3.amazonaws.com/uploads/products/2/prod1.jpg" 

이미지는 이름과 확장자를 표시합니다. 경로가 아닙니다. 이게 정상인가?

product> 
    <attachment>prod1.jpg</attachment> 
    <cached-slug>adsfsadf</cached-slug> 
    <category-id type="integer">1</category-id> 
    <company-id type="integer">1</company-id> 
    <created-at type="datetime">2011-05-10T05:10:35Z</created-at> 
    <description>description here</description> 
    ... 

답변

1

그래, 내가 Carrierwave는 (방법 내에서) 동적 URL을 생성하는 생각, 그래서 당신은 변경하거나 계산하는 방식을 재정의 할 수

예를 들어, XML은 것 같습니다.

format.xml { render :xml => @product.to_xml(:include => {:attachment => {:only => :url}}) } 

는 편집 : 나를 위해 작품 :

format.xml { render :xml => @product.to_xml(:except => :attachment, :methods => :attachment_url) } 
+0

내가 전무에 대한 '정의되지 않은 메서드'매크로를 얻을 : NilClass –

+1

내 편집에서 봐, 난 그냥 당신을 위해 그것을 밖으로 시도 :) –

관련 문제