# Attachement\_fu does not upload images

**URL:** <https://www.ruby-forum.com/t/attachement-fu-does-not-upload-images/145952>\
**Category:** Rails\
**Created:** [August 15, 2008, 1:02pm UTC](https://www.ruby-forum.com/t/attachement-fu-does-not-upload-images/145952 "2008-08-15T13:02:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![shuaib85](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/bbce88/32.png) [@shuaib85](https://www.ruby-forum.com/u/shuaib85)\
**Post date:** [August 15, 2008, 1:02pm UTC](https://www.ruby-forum.com/t/attachement-fu-does-not-upload-images/145952/1 "2008-08-15T13:02:00Z")

</div>

dear all

I followed [http://clarkware.com/cgi/blosxom/2007/02/24](http://clarkware.com/cgi/blosxom/2007/02/24)  
i installed ImageScience and FreeImage.  
whenever I create an entry it does not get to the database and it does  
not upload the file

I am not sure what is wrong in the code, especially it is mere copy  
paste 🙂

I added this to  
config/environment.rb  
config.gem ‘image\_science’

config/route.rb  
map.resources :mugshots

this is the code

class Mugshot \< ActiveRecord::Base  
has\_attachment :content\_type =\> :image,  
:storage =\> :file\_system,  
:max\_size =\> 500.kilobytes,  
:thumbnails =\> { :thumb =\> ‘100x100\>’ },  
:processor =\> ‘ImageScience’

```
    validates_as_attachment

```

end

class MugshotsController \< ApplicationController  
def index  
@mugshots = Mugshot.find(:all)  
end  
def new  
@mugshot = Mugshot.new  
end

def create  
@mugshot = Mugshot.new(params[:mugshot])  
if @mugshot.save  
flash[:notice] = ‘Mugshot was successfully created.’  
redirect\_to mugshot\_url(@mugshot)  
else  
render :action =\> :new  
end  
end

end

new.html.erb

\<%= error\_messages\_for :mugshot %\>

\<% form\_for(:mugshot, :url =\> mugshots\_path,  
:html =\> { :multipart =\> true }) do |f| -%\>

Upload A Mugshot: \<%= f.file\_field :uploaded\_data %\>

\<%= submit\_tag 'Create' %\>

\<% end -%\>

index.html.erb

# Most Wanted
\<% for mugshot in @mugshots -%\> \<%= link\_to image\_tag(mugshot.public\_filename(:thumb)), mugshot.public\_filename %\> \<% end -%\>

this is what i get from the log

Processing MugshotsController#new (for 127.0.0.1 at 2008-08-15  
18:43:24) [GET]  
Session ID:  
BAh7BzoMY3NyZl9pZCIlNjNjMGFiZGY4OGIxNzMzNTJlY2NkNWU0YmY5ZWMz  
ODMiCmZsYXNoSUM6J0FjdGlvbkNvbnRyb2xsZXI6OkZsYXNoOjpGbGFzaEhh  
c2h7AAY6CkB1c2VkewA=–a3b1e1c814f7d712aaf16820f4db2041b4a0d785  
Parameters: {“action”=\>“new”, “controller”=\>“mugshots”}  
SQL (0.000184) SET NAMES ‘utf8’  
SQL (0.000098) SET SQL\_AUTO\_IS\_NULL=0  
Mugshot Columns (0.000911) SHOW FIELDS FROM `mugshots`  
Rendering mugshots/new  
Completed in 0.03245 (30 reqs/sec) | Rendering: 0.00226 (6%) | DB:  
0.00119 (3%) | 200 OK [[http://localhost/mugshots/new](http://localhost/mugshots/new)]

Processing MugshotsController#index (for 127.0.0.1 at 2008-08-15  
18:43:27) [POST]  
Session ID:  
BAh7BzoMY3NyZl9pZCIlNjNjMGFiZGY4OGIxNzMzNTJlY2NkNWU0YmY5ZWMz  
ODMiCmZsYXNoSUM6J0FjdGlvbkNvbnRyb2xsZXI6OkZsYXNoOjpGbGFzaEhh  
c2h7AAY6CkB1c2VkewA=–a3b1e1c814f7d712aaf16820f4db2041b4a0d785  
Parameters: {“commit”=\>“Create”,  
“authenticity\_token”=\>“f4c278ba18f30630d063c45f4d5bb84000f7682c”,  
“action”=\>“index”, “controller”=\>“mugshots”,  
“mugshot”=\>{“uploaded\_data”=\>#\<File:/tmp/CGI21597-1\>}}  
Mugshot Load (0.001881) SELECT \* FROM `mugshots`  
Rendering mugshots/index  
Completed in 0.01364 (73 reqs/sec) | Rendering: 0.00134 (9%) | DB:  
0.00188 (13%) | 200 OK [[http://localhost/mugshots](http://localhost/mugshots)]

Processing MugshotsController#index (for 127.0.0.1 at 2008-08-15  
18:44:44) [POST]  
Session ID:  
BAh7BzoMY3NyZl9pZCIlNjNjMGFiZGY4OGIxNzMzNTJlY2NkNWU0YmY5ZWMz  
ODMiCmZsYXNoSUM6J0FjdGlvbkNvbnRyb2xsZXI6OkZsYXNoOjpGbGFzaEhh  
c2h7AAY6CkB1c2VkewA=–a3b1e1c814f7d712aaf16820f4db2041b4a0d785  
Parameters: {“commit”=\>“Create”,  
“authenticity\_token”=\>“f4c278ba18f30630d063c45f4d5bb84000f7682c”,  
“action”=\>“index”, “controller”=\>“mugshots”,  
“mugshot”=\>{“uploaded\_data”=\>#\<File:/tmp/CGI21597-3\>}}  
Mugshot Load (0.000139) SELECT \* FROM `mugshots`  
Rendering mugshots/index  
Completed in 0.01159 (86 reqs/sec) | Rendering: 0.00081 (6%) | DB:  
0.00014 (1%) | 200 OK [[http://localhost/mugshots](http://localhost/mugshots)]
