I'm trying to add captions to images and have been struggling with
editing the admin/product_controller to update my caption.
I have added the column, added the method, added the form box which
correctly loads the text, however when I try to save it - it simply
does not work. I feel I have tried every variation possible to try to
save the params. I would really appreciate help and hopefully the
answer will help other people as well.
## This actually saves to the caption but only when it is created
unless params[:image].blank?
params[:image].each do |i|
if i[:image_data] && !i[:image_data].blank?
new_image = Image.new
new_image.caption = "test"
logger.info i[:image_data].inspect
new_image.uploaded_data = i[:image_data]
if new_image.save
@product.images << new_image
else
image_errors.push(new_image.filename)
end
end
end
end
I have tried
@product.images[0].caption
@image.caption
params[:image].caption
i[:image_data].caption
pi = ProductImage.find(
:first,
:conditions => ["image_id = ? AND product_id = ?",
params[:image_list][i], params[:id]]
)
pi.caption
and none of them work. For testing purposes I tried to setting the r-
value to "test".
I would really appreciate any help.