Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

355
Views
Using Webcam in Ruby on Rails

I have a rails app with a sign-up page, where users fill in a form with their details. I want to add a field for user's picture: rather than uploading it, I want the user to take a picture using their webcam. The picture is supposed to be saved to the disk and the DB to be updated with its name and path.

How can I do this? I know that the storage was previously handled by paperclip but it is nowadays done using Active Storage, but what about using the webcam? googling "ruby gem webcam" and limiting results to the last year has been surprisingly unhelpful, with most results being porn-related.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

If you want to use the webcam then you'll need to handle that side of things in JavaScript. You would need to use the getUserMedia API to get access to the camera stream. Once you've got that, you can capture a still by writing frames from the camera into a canvas, then exporting the canvas to an image with Canvas.toDataBlob.

Some browsers expose more access to the camera for capturing images, but you'll still get a blob eventually.

Once you've got that, you can add it to a FormData object and submit to your Rails app at which point Active Storage can take over storing the file.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!