Error with attachment_fu

Hello

I am using attachment_fu and RMagick to raise photos, to change the size
and to create a thumbnail.

The case that when I add an image, the first time does well and
rest gives to error when doing save in the controller. So I must stop
the servant and to return to arranzar it and then raises it…

My code is this:
new.rhtml

New mugshot

<%= error_messages_for :whatever %>

<% form_for(:mugshot, :url => { :action => “create” },
:html => { :multipart => true }) do |f| -%>

Upload A Mugshot: <%= f.file_field :uploaded_data %>

<%= submit_tag 'Create' %>

<% end -%>

Controller

class MugshotsController < ApplicationController
def show
@mugshot = Mugshot.find(:all)
end

def create
@mugshot = Mugshot.new(params[:mugshot])
if @mugshot.save
flash[:notice] = ‘Photo saved successfully!’
render :action => “show”
else
flash[:notice] = ‘There was a problem!’
render :action => “new”
end
end
end

Model

class Mugshot < ActiveRecord::Base

has_attachment :content_type => :image,
:storage => :file_system,
:max_size => 2.megabyte,
:resize_to => ‘640x480>’,
:path_prefix => “./public/images”,
:thumbnails => { :thumb => ‘100x100>’ },
:processor => :Rmagick

    validates_as_attachment

end

Log OK

Processing MugshotsController#create (for 127.0.0.1 at 2007-10-06
12:03:35) [POST]
Session ID: a4a498d39b73b6c85343af2121023339
Parameters: {“commit”=>“Create”, “action”=>“create”,
“controller”=>“mugshots”,
“mugshot”=>{“uploaded_data”=>#<File:C:/DOCUME~1/ADMINI~1/CONFIG~1/Temp/CGI5456-1>,
“establishment_id”=>“1”}}
e[4;36;1mSQL (0.000000)e[0m e[0;1mSET SQL_AUTO_IS_NULL=0e[0m
e[4;35;1mMugshot Columns (0.000000)e[0m e[0mSHOW FIELDS FROM
mugshotse[0m
e[4;36;1mSQL (0.000000)e[0m e[0;1mBEGINe[0m
e[4;35;1mSQL (0.000000)e[0m e[0mINSERT INTO mugshots
(content_type, size, thumbnail, establishment_id, filename,
height, parent_id, width) VALUES(‘image/pjpeg’, 1321783, NULL, 1,
‘PC030030.JPG’, 480, NULL, 640)e[0m
e[4;36;1mMugshot Load (0.015000)e[0m e[0;1mSELECT * FROM mugshots
WHERE (mugshots.thumbnail = ‘thumb’ AND mugshots.parent_id = 31)
LIMIT 1e[0m
e[4;35;1mSQL (0.000000)e[0m e[0mINSERT INTO mugshots
(content_type, size, thumbnail, establishment_id, filename,
height, parent_id, width) VALUES(‘image/pjpeg’, 117200, ‘thumb’,
NULL, ‘PC030030_thumb.JPG’, 75, 31, 100)e[0m
e[4;36;1mSQL (0.079000)e[0m e[0;1mCOMMITe[0m
Rendering layoutfalseactionshow within layouts/mugshots
Rendering mugshots/show
Completed in 1.89000 (0 reqs/sec) | Rendering: 0.01500 (0%) | DB:
0.09400 (4%) | 200 OK [http://localhost/mugshots/create]

Log ERROR

Processing MugshotsController#create (for 127.0.0.1 at 2007-10-06
12:04:14) [POST]
Session ID: a4a498d39b73b6c85343af2121023339
Parameters: {“commit”=>“Create”, “action”=>“create”,
“controller”=>“mugshots”,
“mugshot”=>{“uploaded_data”=>#<File:C:/DOCUME~1/ADMINI~1/CONFIG~1/Temp/CGI5456-1>,
“establishment_id”=>“1”}}
e[4;35;1mMugshot Columns (0.016000)e[0m e[0mSHOW FIELDS FROM
mugshotse[0m
e[4;36;1mSQL (0.000000)e[0m e[0;1mBEGINe[0m
e[4;35;1mSQL (0.000000)e[0m e[0mCOMMITe[0m
Rendering layoutfalseactionnew within layouts/mugshots
Rendering mugshots/new
Completed in 0.48400 (2 reqs/sec) | Rendering: 0.01500 (3%) | DB:
0.01600 (3%) | 200 OK [http://localhost/mugshots/create]

I see several things that not if they are correct:

  1. The temporary file of the photo is called equal in the cases.
    OK–> <File: C: /DOCUME~1/ADMINI~1/CONFIG~1/Temp/CGI5456-1>
    KO–> <File: C: /DOCUME~1/ADMINI~1/CONFIG~1/Temp/CGI5456-1>

  2. In that it has gone well before insert makes “SETH
    SQL_AUTO_IS_NULL=0”.
    Could be a problem of bbdd?

Thank you very much.

Please help… :((((

What’s the error?

On 10/7/07, Ramón Castro [email protected] wrote:

Please help… :((((


Ramon T.

Solved the problem.

I have had to change the model.
It had
: max_size => 2.megabyte

And it has been solved with
: size => 0.kilobytes…3.megabytes,

Thank you very much

The error is that when I take the servant I can raise a photo, but the
following ones give error me. And I must reinitiate the servant to be
able to raise another one…

Thank you very much.