ActiveScaffold Camera
Adds a camera interface to Active Scaffold forms so users can capture a snapshot from an available camera.
Description
ActiveScaffold Camera adds the :snapshot form UI. It displays a camera preview, captures a PNG when the user clicks the video, and submits the result in the column’s form field as a base64-encoded data URL.
The gem requires Active Scaffold 3.4 or newer.
Browser compatibility: version 0.2.0 uses the modern navigator.mediaDevices API when available, including getUserMedia(), enumerateDevices(), and deviceId constraints. It retains the callback-based API, MediaStreamTrack.getSources, and sourceId constraints as fallbacks for older browsers. Camera access requires a secure context (HTTPS or localhost) and the user’s permission.
Installation
Add the following line to your Gemfile:
gem 'active_scaffold_camera'Then run:
bundle installUsage & Options
Enable the camera functionality in your controller:
class ProfilesController < ApplicationController
active_scaffold :profile do |config|
config.columns[:id_card].form_ui = :snapshot, { source: -1 }
end
endThe available options are video_not_supported, audio_not_supported, media_forbidden, and source.
Set source to a camera index to skip the source selector. Negative indexes count back from the end of the camera list. If that index does not identify a camera, the plugin falls back to the first available camera.
The other options customize error messages. A symbol is translated through Active Scaffold’s as_ helper and must have a translation in the active_scaffold namespace. Default English and Spanish translations are included.
Saving the snapshot
The form UI submits a complete PNG data URL, not raw image bytes, and it should be stored in a blob column. The plugin does not decode the data URL or attach it to a file-storage service.
Support
For help, use the Active Scaffold discussion group or open an issue.
