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
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---