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
--------------------------
<h1>New mugshot</h1>
<%= error_messages_for :whatever %>
<% form_for(:mugshot, :url => { :action => "create" },
:html => { :multipart => true }) do |f| -%>
<input id="mugshot_establishment_id"
name="mugshot[establishment_id]"
type="hidden" value="1">
<p>
<label for="mugshot">Upload A Mugshot:</label>
<%= f.file_field :uploaded_data %>
</p>
<p>
<%= submit_tag ''Create'' %>
</p>
<% 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"}}
[4;36;1mSQL (0.000000) [0;1mSET SQL_AUTO_IS_NULL=0
[4;35;1mMugshot Columns (0.000000) SHOW FIELDS FROM
mugshots
[4;36;1mSQL (0.000000) [0;1mBEGIN
[4;35;1mSQL (0.000000) INSERT INTO mugshots
(`content_type`, `size`, `thumbnail`, `establishment_id`, `filename`,
`height`, `parent_id`, `width`) VALUES(''image/pjpeg'', 1321783,
NULL, 1,
''PC030030.JPG'', 480, NULL, 640)
[4;36;1mMugshot Load (0.015000) [0;1mSELECT * FROM mugshots
WHERE (mugshots.`thumbnail` = ''thumb'' AND mugshots.`parent_id`
= 31)
LIMIT 1
[4;35;1mSQL (0.000000) INSERT 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)
[4;36;1mSQL (0.079000) [0;1mCOMMIT
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"}}
[4;35;1mMugshot Columns (0.016000) SHOW FIELDS FROM
mugshots
[4;36;1mSQL (0.000000) [0;1mBEGIN
[4;35;1mSQL (0.000000) COMMIT
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.
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---