Forum: Ruby on Rails rescue problem and attachment_fu

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Pawel J. (Guest)
on 2007-07-10 18:01

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

 def create

 Image.transaction do
 params[:images].collect { |image| @gallery.images << => image) }
 redirect_to admin_gallery_url(@gallery)
 rescue ActiveRecord::RecordInvalid
 render admin_gallery_url(@gallery)
 end unless params[:images].nil?


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
This topic is locked and can not be replied to.