# Rescue problem and attachment\_fu

**URL:** <https://www.ruby-forum.com/t/rescue-problem-and-attachment-fu/109005>\
**Category:** Rails\
**Created:** [July 10, 2007, 4:01pm UTC](https://www.ruby-forum.com/t/rescue-problem-and-attachment-fu/109005 "2007-07-10T16:01:10Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![pabloz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c37758/32.png) [@pabloz](https://www.ruby-forum.com/u/pabloz)\
**Post date:** [July 10, 2007, 4:01pm UTC](https://www.ruby-forum.com/t/rescue-problem-and-attachment-fu/109005/1 "2007-07-10T16:01:10Z")

</div>

Hello

I have a following method in my image controller. It should add images  
to existing gallery.

def create

Image.transaction do  
begin  
params[:images].collect { |image| @gallery.images \<\<  
Image.new(:uploaded\_data =\> image) }  
redirect\_to admin\_gallery\_url(@gallery)  
rescue ActiveRecord::RecordInvalid  
render admin\_gallery\_url(@gallery)  
end  
end unless params[:images].nil?

end

I am using attachment\_fu as my image plugin. It works fine, except i  
can’t see validation errors. Validation WORKS because wrong files do not  
get saved in a database. I am also making a transaction since  
params[:images] is an array of file elements so i want to save all or  
nothing. I am trying to use rescue to render a template so i can see  
validation errors but it doesn’t work.(like it doesnt care about rescue)  
I am a begginer, is this the right way to go with this problem? and why  
doesn’t this work 🙂

In my image model i have ofcourse  
validates\_as\_attachment
