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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:18:07+00:00 2026-05-22T18:18:07+00:00

I read this nice writeup on using Paperclip in a rails3 app to capture

  • 0

I read this nice writeup on using Paperclip in a rails3 app to capture pictures from a webcam.

I’m trying to convert it to use Carrierwave (I use it on other apps which will all be sharing the same images, so I want to be consistent).

What I’m struggling with is how to get Carrierwave to accept the file from the flash image capture from jpegcam. Seems like Paperclip is more file oriented, and Carrierwave is more object oriented.

Here’s what I’m trying:

I have a model with the carrierwave uploader mounted on it:

class Individual < ActiveRecord::Base

  mount_uploader :picture, PictureUploader

And in the view (an “edit” view):

#webcam
  = embed{:id => 'webcam_movie'}... (the embedded flash)...

= submit_tag "Take picture", :onclick => 'webcam.snap();'

= form_for @individual, :html => {:multipart => true} do |f|
  = f.text_field :firstname
  = f.text_field :lastname
  = f.file_field :picture
  = f.submit

= content_for :javascripts do
  :javascript
    function upload_complete(msg) {
       if (msg) {
           ????
     } else {
       alert('An error occured');
       webcam.reset();
     }
   }
   webcam.set_hook('onComplete', 'upload_complete');

My problem is that Carrierwave doesn’t really have an ‘upload’ function, rather it uses a model object. So I’m not really sure what to put in the controller to get it to accept the file. And how to process the callback in javascript. (I tried a couple of things that I’m too embarrassed to reproduce here. Got the image object to the controller, but couldn’t figure out how to get it processed)

Can anyone help me out? Thanks.

  • 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-22T18:18:08+00:00Added an answer on May 22, 2026 at 6:18 pm

    I ended up fixing this with a huge hack.

    In my controller I did:

    def upload
      @individual = Individual.find(params[:individual_id])
      File.open(upload_path, 'w:ASCII-8BIT') do |f|
        f.write request.raw_post
      end
      @individual.picture = File.open(upload_path)
      if @individual.save!
        render :text => "ok"
      end
    end
    
    private
    
    def upload_path # is used in upload and create
      file_name = 'temp.jpg'
      File.join(::Rails.root.to_s, 'public', 'uploads', file_name)
    end
    

    So I write the imiage out to a file, which carrierwave then reads in. (Of course carrierwave also makes a temp copy of the file).

    This is very ugly, and probably offends all the Rails Gods, but it works.

    I asked the question on the carrierwave list whether I could cut out the temp file bit and somehow just read the “request.raw_post” into the uploader object, but it’s not clear that I can.

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

Sidebar

Related Questions

I just read this nice article that taught me how to use inheritance (Table-per-hirarchy).
I've just read this nice piece from Reddit. They mention and and or being
I read this post last night, and I noticed it was from 2006. I
I just read this nice answer given on how to compare floating-point values for
I received this code from one of those nice people here who are willing
I recently read this thread on MSDN . So I was thinking of using
I need help remembering what book I read this from, It might have been
I have just read this [very nice] small tutorial about MYSQL error handling. I
#It is possible! Read below. First of all, let me use this diagram to
I read this PHP RegEx page , but either I'm missing something, misreading something,

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.