# Error with attachment\_fu

**URL:** <https://www.ruby-forum.com/t/error-with-attachment-fu/116512>\
**Category:** Rails\
**Created:** [October 6, 2007, 12:29pm UTC](https://www.ruby-forum.com/t/error-with-attachment-fu/116512 "2007-10-06T12:29:32Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![zaid](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/e95f7d/32.png) [@zaid](https://www.ruby-forum.com/u/zaid)\
**Post date:** [October 6, 2007, 12:29pm UTC](https://www.ruby-forum.com/t/error-with-attachment-fu/116512/1 "2007-10-06T12:29:32Z")

</div>

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](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](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.

---

<div class="post-metadata">

**Author:** ![zaid](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/e95f7d/32.png) [@zaid](https://www.ruby-forum.com/u/zaid)\
**Post date:** [October 7, 2007, 3:47pm UTC](https://www.ruby-forum.com/t/error-with-attachment-fu/116512/2 "2007-10-07T15:47:52Z")

</div>

Please help… :((((

---

<div class="post-metadata">

**Author:** ![zaid](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/e95f7d/32.png) [@zaid](https://www.ruby-forum.com/u/zaid)\
**Post date:** [October 7, 2007, 5:51pm UTC](https://www.ruby-forum.com/t/error-with-attachment-fu/116512/3 "2007-10-07T17:51:27Z")

</div>

What’s the error?

On 10/7/07, Ramón Castro [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Please help… :((((

–  
Ramon T.

---

<div class="post-metadata">

**Author:** ![zaid](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/e95f7d/32.png) [@zaid](https://www.ruby-forum.com/u/zaid)\
**Post date:** [October 7, 2007, 6:33pm UTC](https://www.ruby-forum.com/t/error-with-attachment-fu/116512/4 "2007-10-07T18:33:55Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![zaid](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/e95f7d/32.png) [@zaid](https://www.ruby-forum.com/u/zaid)\
**Post date:** [October 7, 2007, 6:16pm UTC](https://www.ruby-forum.com/t/error-with-attachment-fu/116512/5 "2007-10-07T18:16:39Z")

</div>

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.
