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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:48:44+00:00 2026-05-26T11:48:44+00:00

I’ve been looking for a way to set up Ruby on Rails 3.1 with

  • 0

I’ve been looking for a way to set up Ruby on Rails 3.1 with Paperclip and jQuery fileupload. Looking at a tutorial at jQuery fileupload page I got the system set up but I can’t find a way to make paperclip process the uploaded file.

Here’s what I have (in short):

# model
has_attached_file :photo ...

# view
= form_for @user, :html => {:multipart => true} do |f|
  f.file_field :photo, :multiple => true
  f.submit

# controller
def create
  @user = User.new params[:user]
  if @user.save
    render :json => [...]
end

If I inspect submitted data I get all user properties in params[:user] and params[:user][:photo] which is ActionDispatch::Http::UploadedFile. When @user.save is called the image doesn’t get processed or saved.

A clue, tutorial or a solution would be much appreciated!

  • 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-26T11:48:45+00:00Added an answer on May 26, 2026 at 11:48 am

    After struggling with this problem for a while I discovered the problem appeared when :multipart => true is added to the f.file_field since the form field name changes from user[photo] to user[photo][].

    Using separate page to attach photos

    I want to have a separate page for uploading multiple files to a record (and another one for editing User’s properties). This looks to me as a temporary solution but it works. Instead of f.form_field :photo, :multipart => true I used form_field_tag 'user[photo]', :multiple => true in the view.

    My code looks like this:

    ## app/model/user.rb
    has_attached_file :photo
    
    def to_fileupload_json
      {
        "name" => photo_file_name,
        "size" => photo_file_size,
        ...
      }
    end
    
    ## app/views/photos/new.html.haml
    = form_for @user, :url => users_path, :html => { :multipart => true } do |f|
      #fileupload
        = file_field_tag 'user[photo]', :multiple => true
        = f.submit
    
    = javascript_include_tag "jquery.fileupload.js"
    # require all other JS files needed for the plugin (jQuery, jQuery UI, ...)
    = stylesheet_link_tag "jquery.fileupload-ui.css"
    = render :partial => "jquery_file_templates" # partial with jQuery templates for responses 
    
    :javascript
      $(function () {
          uploader = $('#fileupload').fileupload()
      }
    
    
    ## app/controllers/users_controller.rb
    def create
      @user = User.create params[:user]
    end
    

    If anyone else knows a better way (the right way) of doing this, please let us know!

    Using fields_for

    Depending on the structure of your app you might consider using fields_for.

    In this case you’ll have to:

    • add accepts_nested_attributes_for :photos to your (User) model
    • add a method photos_attribues=(attributes) to your (User) model and handle record creation there
    • build record for photos 3.times { @user.photos.build } in User’s new method

    Example:

    def photos_attribues=(attributes)
      attributes.each do |key, value|
        photo = Photo.create :photo => value, ...
      end
    end
    

    Disclaimer: The code above was simplified/rewritten to make it easier to understand. I might’ve made mistakes while erasing unneeded stuff. And again – I’m not really sure this is the right way of solving this problem. Suggestions and improvements are more than welcome!

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

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
Basically, what I'm trying to create is a page of div tags, each has
I've got a string that has curly quotes in it. I'd like to replace
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build

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.