Upload_column problems on post after validation error

Hi to all the crew !

I’ve a little (big ?) problem.

I’m using upload_column plugin, it works very well but it throws an
exception when I try to repost the form after a validation error.

Here some details:

Model: (hostel.rb)

HOSTEL_PHOTO_DIR = Proc.new {|inst, attr| “hostel/#{inst.id}”}
HOSTEL_PHOTO_THUMB = “100x100”
HOSTEL_PHOTO_NORMAL = “400x400”

image_column :photo_1, :store_dir => HOSTEL_PHOTO_DIR,
:versions => { :thumb => HOSTEL_PHOTO_THUMB,
:normal => HOSTEL_PHOTO_NORMAL},
:filename => Proc.new {|inst, orig, ext|
“photo_1.#{ext}”}

View (signup_customer.rhtml):
<% upload_form_tag :action => “update_customer” do %>

Photo 1
<%= upload_column_field “hostel”, “photo_1” %>
<% end %>

Controller:
def update_customer
begin

hostel.attributes = params[:hostel] # Where the error
occurred…
hostel.save!
rescue
@hostel = hostel
render :action => “signup_customer”
end
end

Now, if I post the form without validation exception, all works good !!!

But if I try to post the form without a required field I give an
exception and the controller show the form again, if I put the required
data and post again I receive this exception:

invalid format of ‘hostel/117/photo_1.jpg;0182-Problemi-gravi.jpg’

|vendor/plugins/uploadcolumn/lib/upload_column.rb:431:in set_path' vendor/plugins/uploadcolumn/lib/upload_column.rb:809:insend’
vendor/plugins/uploadcolumn/lib/upload_column.rb:809:in photo_1_temp=' /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/base.rb:1672:insend’
/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/base.rb:1672:in
attributes=' /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/base.rb:1671:ineach’
/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/base.rb:1671:in
attributes=' /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/associations/association_proxy.rb:123:insend’
/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/associations/association_proxy.rb:123:in
method_missing' app/controllers/hostel_controller.rb:53:inupdate_customer’|

At line 53 in hostel_controller.update_customer there is the line:

  hostel.attributes = params[:hostel]   # Where the error 

occurred…

I don’t know how to solve this problem !!!

Can you help me ???

Thanks in advance !!!

Tex.

That’s because it tryes to assign photo_1_temp before photo_1.

This should work:
def update_customer
begin

hostel.attributes = params[:hostel][:photo_1] if
params[:hostel][:photo_1]
hostel.attributes = params[:hostel] # Where the error occurred

hostel.save!
rescue
@hostel = hostel
render :action => “signup_customer”
end
end