[英]Image using paperclip
Using Rails 2.3.15
and paperclip 2.3.0
使用Rails 2.3.15
和paperclip 2.3.0
It is easy to display image as follows: ie 显示图像很容易如下:
@product.img_url.url
Now, I have join on two tables and from the result of the join I want to fetch and show the image. 现在,我已经在两个表上进行了联接,根据联接的结果,我想获取并显示图像。
eg 例如
@searchItems = Product.find(:all, :select => "p.id, p.title, p.img_url, p.img_url_file_name, p.img_url_content_type, p.img_url_file_size, p.url, pp.selling_price",
:conditions => "p.category = 'Mobiles'",
:joins => "as p inner join product_pricings as pp on p.id = pp.product_id")
searchItems
is an array
. searchItems
是一个array
。 How do I get image from the array
, like I get from model. 我如何从array
获取图像,就像我从模型中获取图像一样。
Any help would help me lot. 任何帮助都会对我有很大帮助。
Isn't 是不是
@searchItems.each do |product|
do_something_with(product.img_url.url)
end
what you mean? 你是什么意思?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.