Rails demo reference
The Rails source is on GitHub.
fly launch will provide a Dockerfile
and a fly.toml config file. fly launch will
also work with Rails-provided Dockerfiles. When you make changes to your application, you can run
bin/rails generate dockerfile to generate updated Dockerfiles.
How the pieces are put together:
- The original web-dictaphone app distributed throughout the application:
app/javascript/controllers/main_controls_controllerandapp/javascript/controllers/sound_clip_controllercontain the JavaScript, implemented as Stimulus controllers.app/assets/stylesheets/dictaphone.csscontains the stylesheets.app/views/clips/index.html.erbcontains the HTML
- Active Record will run using Sqlite3 as the database in development mode, and
PostgreSQL in production.
Access to the database is through the
DATABASE_URLsecret. - Active Storage is configured to write to the filesystem
in development and Tigris in production. The following secrets are used to
establish the connection:
AWS_ACCESS_KEY_ID,AWS_ENDPOINT_URL_S3,AWS_REGION,AWS_SECRET_ACCESS_KEY, andBUCKET_NAME. - Action Cable is configured to use an Async adapter in development and the Redis adapter in production.
Key points of logic:
app/controllers/clips_controller.rbcontains the logic to build responses to requests for the index page, and to GET, PUT, and DELETE audio clips.- The realtime implementation code is primarily in ActionCable, so all that is needed is one line in
app/models/clip.rband one line inapp/views/layouts/application.html.erb - When the
WHISPER_URLsecret is set,PUTrequests will cause the audio clips to be passed to the Whisper server, and responses will be used to update the PostgreSQL database. This is done using Active Job and Sidekiq. The code for this is inapp/jobs/whisper_transcribe_job.rb.