Forum: Ruby on Rails Updating with Paperclip

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
David (Guest)
on 2009-02-06 09:12
(Received via mailing list)
I cannot seem to get paperclip working for my file uploads after
switching from attachment_fu.  I have the correct fields migrated into
the database, have included   has_attached_file :photo, :styles =>
{ :thumb => "175x175>" } in my mode, but no photo is ever saved in the
database and there are no errors.  Looking in the console I noticed
that it says paperclip is "Saving files for photo" and then on the
next line "Deleting files for photo".  Im wondering if this is a clue
to my problem?  The surrounding output is below:

Processing SpecController#update (for 127.0.0.1 at 2009-02-05
23:05:11) [PUT]
  Session ID:
BAh7CDoJdXNlcmkHOgxjc3JmX2lkIiVlNDdkZjcwNWY0YzViODRlOTZjNGJi
M2FiMTU4YzMxOCIKZmxhc2hJQzonQWN0aW9uQ29udHJvbGxlcjo6Rmxhc2g6
OkZsYXNoSGFzaHsABjoKQHVzZWR7AA==--
be12b27be21dd16e1c3fe915b78e06d0173a08c2
  Parameters: {"commit"=>"Upload",
"authenticity_token"=>"0116a623cd3b784f7c81539c52b6e0c04cf0c611",
"_method"=>"put", "action"=>"update", "spec"=>{"photo"=>"Blue-Wild-
Flower-1-1024x768.jpg"}, "id"=>"10", "controller"=>"spec"}
  User Columns (0.006779)   SHOW FIELDS FROM `users`
  User Load (0.028061)   SELECT * FROM `users` WHERE (`users`.`id` =
2)
  CACHE (0.000000)   SELECT * FROM `users` WHERE (`users`.`id` = 2)
  Spec Load (0.000263)   SELECT * FROM `specs` WHERE (`specs`.user_id
= 2) LIMIT 1
  Spec Columns (0.002173)   SHOW FIELDS FROM `specs`
[paperclip] Paperclip attachment photo on Spec initialized.
  SQL (0.001320)   BEGIN
[paperclip] Saving attachments.
[paperclip] Saving files for photo
[paperclip] Deleting files for photo
[paperclip] Writing files for photo
  SQL (0.000070)   COMMIT
  CACHE (0.000000)   SELECT * FROM `users` WHERE (`users`.`id` = 2)
Completed in 0.06918 (14 reqs/sec) | Rendering: 0.00947 (13%) | DB:
0.03867 (55%) | 200 OK [http://localhost/spec/10]


This is my controller action(for testing):

 def update
    @spec = logged_in_user.spec || logged_in_user.spec.build(params
[:spec])
    @spec.update_attributes(params[:spec])
  end

Anyone have any ideas, this is driving me crazy.
Tony C. (Guest)
on 2009-02-06 17:33
> "_method"=>"put", "action"=>"update", "spec"=>{"photo"=>"Blue-Wild-
> Flower-1-1024x768.jpg"}, "id"=>"10", "controller"=>"spec"}

If you can see the file name and not something like :
"photo"=>#<ActionController::UploadedStringIO:0xb70611f4>

There's a mistake. Maybe you forgot the multipart on the form?
This topic is locked and can not be replied to.