dear all
I followed 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]
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]
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]