Carrierwave is not displaying file path in xml view - Is this normal?
I've got an app that works with Carrierwave. I can even do something like @product.image.url which will give me the path to url of the stored image.
However, when I browse to products#show (i.e. http://localhost:3000/products/1.xml), it displays everything correctly except for the image.
In the console, @product.image.url, returns:
"https://bucket_name.s3.amazonaws.com/uploads/products/2/prod1.jpg"
The image only displays the name and the extension. Not the path. Is this normal?
For example, the xml looks like:
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</de开发者_运维问答scription>
...
Yep, I think Carrierwave is generating the url dynamically (within a method), so you can change or override the way its computed.
format.xml { render :xml => @product.to_xml(:include => {:attachment => {:only => :url}}) }
EDIT : Works for me :
format.xml { render :xml => @product.to_xml(:except => :attachment, :methods => :attachment_url) }
精彩评论