Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6947399
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:41:18+00:00 2026-05-27T13:41:18+00:00

I have spent 3 days trying to solve this: I am trying to let

  • 0

I have spent 3 days trying to solve this:

I am trying to let users upload their profile picture on my site, using Paperclip.

Everything works fine, until user clicks the Upload button ( he is able to browse and choose a picture). When clicking upload button, Paperclip does not create files (original, small, medium & thumb version of the original picture), instead I got a routing error and no folder, no file is created, the :id field in the path looks empty, and the ‘paperclip’s attribute’ are all set to NIL…

The Users controller:

def edit
    @user = User.find(params[:id])
    @title = "Upload a profile picture"
  end

  def update
    @user = User.create(params[:user])
    @title = "Update a profile picture"
  end`

The views:

edit.html.erb:

<h1>
    Ajouter une photo au profil
</h1>

<%= form_for @user,:user, :html => { :multipart => true} do |f| %>
<div class="field">  
  <%= f.label :avatar, "Upload ta photo" %>
  <br />
  <%= f.file_field :avatar %>
</div>

<div class="actions">
    <%= f.submit "Upload" %>
</div>
<% end %>

clicks leads to update.html.erb:

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

Last but not least the model User.rb:

class User < ActiveRecord::Base
  attr_accessor :password
  attr_accessible :name, :email, :number_of_positive_reco, :confidence_percent, :password,
                  :password_confirmation, :avatar, :avatar_file_name, :avatar_content_file, :avatar_file_size, :avatar_updated_at

  has_attached_file :avatar , :styles => { :medium => "300x300>", :thumb => "100x100>"},
                    :url => "/public/images/:attachment/:id_:style.:extension",
                    :path => ":rails_root/public/images/:attachment/:id_:style.:extension"
                   # :default_url => "/images/Default_profile_picture.png"

  email_regex = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i

  validates :name, :presence => true,
  :length => { :maximum => 20}
  validates :email, :presence => true,
  :format => { :with => email_regex},
  :uniqueness => {:case_sensitive => false}
  validates :password, :presence => true,
  :confirmation => true,
  :length => { :within => 6..40 }
  validates :number_of_positive_reco, :numericality => {:only_integer => true, :greater_than_or_equal_to => 0}
  validates :confidence_percent, :numericality => { :greater_than_or_equal_to => 0.0, :less_than_or_equal_to => 1.0}

  before_save :encrypt_password
  # Return true if the user's password matches the submitted password.
  def has_password?(submitted_password)
    encrypted_password == encrypt(submitted_password)
  end

  def self.authenticate(email, submitted_password)
    user = find_by_email(email)
    return nil if user.nil?
    return user if user.has_password?(submitted_password)
  end

  def self.authenticate_with_salt(id, cookie_salt)
    user = find_by_id(id)
    (user && user.salt == cookie_salt) ? user : nil
  end

  private

  def encrypt_password
    self.salt = make_salt if new_record?
    self.encrypted_password = encrypt(password)
  end

  def encrypt(string)
    secure_hash("#{salt}--#{string}")
  end

  def make_salt
    secure_hash("#{Time.now.utc}--#{password}")
  end

  def secure_hash(string)
    Digest::SHA2.hexdigest(string)
  end

end

Here is the part of the log, where you SHOULD see paperclip written somewhere, no ?

Processing by UsersController#edit as HTML
  Parameters: {"id"=>"1"}
  User Load (0.7ms)  SELECT "users".* FROM "users" WHERE "users"."id" = 1 LIMIT 1
Rendered layouts/_stylesheets.html.erb (3.6ms)
  User Load (0.9ms)  SELECT "users".* FROM "users" WHERE "users"."id" = 3 LIMIT 1
Rendered layouts/_header.html.erb (7.4ms)
Rendered layouts/_footer.html.erb (2.8ms)
Rendered users/edit.html.erb within layouts/application (55.2ms)
Completed 200 OK in 194ms (Views: 62.5ms | ActiveRecord: 1.6ms)


Started POST "/users/1" for 127.0.0.1 at Fri Dec 09 19:29:19 +0100 2011
  Processing by UsersController#update as HTML
  Parameters: {"commit"=>"Upload", "authenticity_token"=>"c+OuA/dY97fPWukfu4T0nAFEFFg6ty0hK8J3qbGgTJo=", "utf8"=>"���", "id"=>"1", "user"=>{"avatar"=>#<ActionDispatch::Http::UploadedFile:0xb6f31d24 @content_type="image/png", @original_filename="castor.png", @tempfile=#<File:/tmp/RackMultipart20111209-6833-c04i1-0>, @headers="Content-Disposition: form-data; name=\"user[avatar]\"; filename=\"castor.png\"\r\nContent-Type: image/png\r\n">}}
Command :: identify -format %wx%h '/tmp/stream20111209-6833-ms72rm-0.png[0]'
Command :: convert '/tmp/stream20111209-6833-ms72rm-0.png[0]' -resize "100x100>" '/tmp/stream20111209-6833-ms72rm-020111209-6833-ipr2k4-0'
Command :: identify -format %wx%h '/tmp/stream20111209-6833-ms72rm-0.png[0]'
Command :: convert '/tmp/stream20111209-6833-ms72rm-0.png[0]' -resize "300x300>" '/tmp/stream20111209-6833-ms72rm-020111209-6833-1eterfw-0'
  User Load (0.4ms)  SELECT "users"."id" FROM "users" WHERE ("users"."email" IS NULL) LIMIT 1
Rendered layouts/_stylesheets.html.erb (3.1ms)
  User Load (0.7ms)  SELECT "users".* FROM "users" WHERE "users"."id" = 3 LIMIT 1
Rendered layouts/_header.html.erb (5.8ms)
Rendered layouts/_footer.html.erb (2.5ms)
Rendered users/update.html.erb within layouts/application (24.9ms)
Completed 200 OK in 930ms (Views: 31.5ms | ActiveRecord: 1.1ms)


Started GET "/images/avatars/_original.png?1323455359" for 127.0.0.1 at Fri Dec 09 19:29:20 +0100 2011

ActionController::RoutingError (No route matches "/images/avatars/_original.png"):


Rendered /var/lib/gems/1.8/gems/actionpack-3.0.5/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (2.5ms)


Started GET "/images/avatars/_medium.png?1323455359" for 127.0.0.1 at Fri Dec 09 19:29:20 +0100 2011

ActionController::RoutingError (No route matches "/images/avatars/_medium.png"):


Rendered /var/lib/gems/1.8/gems/actionpack-3.0.5/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (1.6ms)


Started GET "/images/avatars/_thumb.png?1323455359" for 127.0.0.1 at Fri Dec 09 19:29:20 +0100 2011

ActionController::RoutingError (No route matches "/images/avatars/_thumb.png"):


Rendered /var/lib/gems/1.8/gems/actionpack-3.0.5/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (1.7ms

So, everything is like: when clicking on upload, Paperclip is unable to store the files in the directory …

In the console mode, I can set the picture without problem.

In the debug mode, I never see “paperclip” written, nowhere … (I was expecting a [Paperclip] Saving attachment” somewhere…also, in the path of the routing error “:id” is set to “” … instead of being the :id of the user, 4 for the 4th user…but even with a default path like “/images/” the problem remains…

Does this make you think about something I may have forgotten ?

(ImageMagick works fine, I have added the multipart true in the form, and normal user has the rights to create a folder)

Many thanks in advance for any hints!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T13:41:18+00:00Added an answer on May 27, 2026 at 1:41 pm

    3 days to find this out: as I used password protection (password being attr_accessor), it’s impossible to update a user, without adding the password field in the form.

    Trying to edit the profile picture without entering the password does not work, and no error message that could have me made me think about this was generated.

    So, in the edit view, don’t forget to add the password field in the form to be able to update user’s picture

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have spent days trying to figure this out to no avail. I have
Have spent an hour trying to solve this - but to no avail. I'm
I have spent three days trying to find the solution to this problem to
I spent days trying to solve this one: I'm trying to create a chart
I have spent days trying to make this work based on the examples in
I've spent a couple of days trying to solve this with limited success, I'm
I have been searching the internet for days trying to solve this problem. I
I'd appreciate if anyone can help me with this; I have spent days trying
I have spent days on this trying out all the JSON libraries including the
I have now spent 2 days trying to get this going. I am however

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.