Topic: help with paperclip please!

Hi,
I'm trying to using paperclip to upload image attached to a user.

after my bundle install i have do :

rails generate paperclip user photo

which create migration and add 4 columns to my user table

in my user model i added

attr_accessible :name, :address, :city, :phone

has_attached_file :photo, styles => {:medium => "300x300>" }

in my _form template

form_for @user, :html => { :multipart => true } do |f|

... form ...

<%= f.label 'photos' %>
<%= f.file_field :photo %>

in my show template

<%= image_tag @user.photo.url(:medium) %>

after i add a user, the show show me default image : missing.png
the path are /photos/medium/missing.png

i followed railscasts tutorial and nothing changed.

how with this method the photo will save in the database?

i'm a bit lost here. does i need to create a model called photo  or a controller called photo? what i missed with the rails tutorial?

thanks a lots.

Re: help with paperclip please!

if it can help. i use WEBrick server.
I'm trying on several rails app created, but same thing, no files saved, and no db entry.

i have noticed in the WEBrick after the INSERT TO i have this message
[paperclip] Saving attachments.

but, where the file are saved
or do you have any other attachment plugin to use?

EDIT : After a validates_attachment_presence :photo, i get a error message.

Invalid Fields

Correct the following errors and try again.

    Photo file name must be set

What that mean?

thanks.

Last edited by neimad (2011-07-28 10:03:12)

Re: help with paperclip please!

I believe you'll need :photo in your attribute_accessible.