Rescue problem and attachment_fu


#1

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 :slight_smile:

In my image model i have ofcourse
validates_as_attachment