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 8719647
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:50:56+00:00 2026-06-13T06:50:56+00:00

So I just added paperclip and migrated it to a table called users_pictures. My

  • 0

So I just added paperclip and migrated it to a table called users_pictures.
My Model looks like this:

class UsersPicture < ActiveRecord::Base
 attr_accessible :user_id, :users_picture_file, :users_picture_id,
                 :photo_file_name, :photo_content_type, :photo_file_size
  belongs_to :users
  has_attached_file :photo,
  :url => "/images/:attachment/:basename.:extension",
  :path => ":rails_root/public/images/:attachment/:basename.:extension"
end

So when I am accessing the “new.html.erb” page, I can add a picture to the form … give it the user_id and submit.
Rails does not show me any errors and the log even says:

Processing by UsersPicturesController#create as HTML

Parameters: {"commit"=>"Create Users picture",`
"authenticity_token"=>"0tbAZj5MKyN/uaj0ybaNsa0dZrxeS05OJNNA3ZNO8Uc=",
"users_picture"=>{"user_id"=>"12", 
"photo"=>#<ActionDispatch::Http::UploadedFile:0xe028dbd4

@content_type="image/jpeg", @tempfile=#<File:/tmp/RackMultipart20121019-14239-1edlwpp-0>, 
@headers="Content-Disposition: form-data; name=\"users_picture[photo]\"; filename=\"rh.jpeg
\"\r\nContent-Type: image/jpeg\r\n", @original_filename="rh.jpeg">}, "utf8"=>"✓"}
[paperclip] Saving attachments.
Redirected to xxxx/users_pictures/8
Completed 302 Found in 18ms (ActiveRecord: 1.2ms)

But the fileinfo is not being saved into database … so I cannot display it.
Firebug tells me something about the parameters for the POST method:

authenticity_token  0tbAZj5MKyN/uaj0ybaNsa0dZrxeS05OJNNA3ZNO8Uc=
users_picture[user_id]  12
users_picture[photo]    ÿØÿà�JFIF������ÿÛ�� !"&# /!$'),,-180*5*+,) 0%"5)-,*4,,,*,),),,,,,,,,,,,,,))),,,*,),,,,),),,,)).,ÿÀ��Ì�Ì"�ÿÄ��������������ÿÄ�E� ����!1AQ"aq2#BRbr¡3²¢±ÁÑ4SÓ%Cs£ÒáÿÄ������������ÿÄ�%��������!1"A2BQq¡ÿÚ���?�Þ4¥()JJRR ¥pLªXl °ôR|¨u]Þýú

And so on.
So it is not saving the path into the database but the sourcecode of the picture?
As you can see, I already set :url and :path (even without the :attachment because I don’t know what it is)

In general, I just wanted to upload pictures to a certain path; and store the file information like name and size in my database.

My form from the view-folder looks like this:

<%= form_for(@users_picture, :html => { :multipart => true }) do |f| %>
...
 <%= f.file_field :photo %>

I will not post the show and index.html.erb because displaying is another thing – I first have to achieve to save all the data in the database + upload the pictures to certain folders.
Any advice on how to do it correctly ?

  • 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-06-13T06:50:57+00:00Added an answer on June 13, 2026 at 6:50 am

    You don’t need to set attr_accessible on those subfields. The only thing you need to mark as attr_accessible is the :photo attribute:

    class UsersPicture < ActiveRecord::Base
      attr_accessible :user_id, :users_picture_file, :users_picture_id, :photo
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've just executed this: rails g scaffold Photos name:string description:string and added paperclip to
I just added a style for an H2 tag like this: h2.section_header { color:
I just added this to my web.xml on my JBOSS server. But it had
I just added a Facebook like button to my website, just the most basic
I just added this SSL middleware to my site http://www.djangosnippets.org/snippets/85/ which I used to
I just added a class library project to my .NET solution. When I built
I just added a new field to my table in mysql and it came
I've just added video uploading with paperclip to a Rails 3 app I have
I just added validations for a carrierwave image to a model and now tests
I just added twitter bootstrap to my website, but it does not seem like

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.