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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T08:24:01+00:00 2026-06-09T08:24:01+00:00

I’m trying to get a simple file upload working using jquery-fileupload-rails carrierwave fog I

  • 0

I’m trying to get a simple file upload working using

  • jquery-fileupload-rails
  • carrierwave
  • fog

I cannot find the cause of the following error

Started POST "/pictures" for 127.0.0.1 at 2012-07-27 15:19:37 +0100
Processing by PicturesController#create as JSON
  Parameters: {"utf8"=>"✓",
  authenticity_token"=>"NKek0e/kfVRUk4SVBjokO5rL446dKvHo9+7mKuH0HKs=", "picture"=>   
  {"path"=>#  <ActionDispatch::Http::UploadedFile:0x00000002d48fa8 
  @original_filename="IMG_0001.JPG", @content_type="image/jpeg", @headers="Content-
  Disposition: form-data; name=\"picture[path]\"; filename=\"IMG_0001.JPG\"\r\nContent-
  Type: image/jpeg\r\n", @tempfile=#<File:/tmp/RackMultipart20120727-7807-1bcbfof>>}}
Completed 500 Internal Server Error in 1ms

ActiveModel::MassAssignmentSecurity::Error (Can't mass-assign protected attributes: 
path):
  app/controllers/pictures_controller.rb:9:in `new'
  app/controllers/pictures_controller.rb:9:in `create'

The model, controller and view are taken from

https://github.com/blueimp/jQuery-File-Upload/wiki/Rails-setup-for-V6

The error message leads me to think that I need to make ‘path’ accessible, but how? Note that the jquery-file-upload bit is working (I have got the bootstrap buttons, the pictures appear on screen, etc, only the file upload itself obviously does not work!)

For completeness, this is picture.rb:

class Picture < ActiveRecord::Base

  include Rails.application.routes.url_helpers
  attr_accessible :avatar
  mount_uploader :avatar, AvatarUploader

  def to_jq_upload
    {
      "name" => read_attribute(:avatar),
      "size" => avatar.size,
      "url" => avatar.url,
      "thumbnail_url" => avatar.thumb.url,
      "delete_url" => picture_path(:id => id),
      "delete_type" => "DELETE" 
    }
  end
end

The corresponding controller is

class PicturesController < ApplicationController  

  def index
    @pictures = Picture.all
    render :json => @pictures.collect { |p| p.to_jq_upload }.to_json
  end

  def create
    @picture = Picture.new(params[:picture])
    @picture.save!
    if @picture.save
      respond_to do |format|
        format.html {  
          render :json => [@picture.to_jq_upload].to_json, 
          :content_type => 'text/html',
          :layout => false
        }
        format.json {  
          render :json => [@picture.to_jq_upload].to_json     
        }
      end
    else 
      render :json => [{:error => "custom_failure"}], :status => 304
    end
  end

  def destroy
    @picture = Picture.find(params[:id])
    @picture.destroy
    render :json => true
  end

end

This is the uploader class:

class AvatarUploader < CarrierWave::Uploader::Base

  storage :file

  def store_dir
    "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
  end


end
  • 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-09T08:24:03+00:00Added an answer on June 9, 2026 at 8:24 am

    I figured out the solution myself: The error was in the view where instead of :path it should read :avatar, and :avatar needs to be accessible. An example implementation where the options for jQuery File Upload are also set can be found at https://github.com/apotry/jquery_fileupload_carrierwave_fog

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

Sidebar

Related Questions

Seemingly simple, but I cannot find anything relevant on the web. What is the
I have just tried to save a simple *.rtf file with some websites and
I am reading a book about Javascript and jQuery and using one of the
I am trying to render a haml file in a javascript response like so:
We're building an app, our first using Rails 3, and we're having to build
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am using Paperclip to handle profile photo uploads in my app. They upload
I'm making a simple page using Google Maps API 3. My first. One marker
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example

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.