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_controller
andapp/javascript/controllers/sound_clip_controller
contain the JavaScript, implemented as Stimulus controllers.app/assets/stylesheets/dictaphone.css
contains the stylesheets.app/views/clips/index.html.erb
contains 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_URL
secret. - 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.rb
contains 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.rb
and one line inapp/views/layouts/application.html.erb
- When the
WHISPER_URL
secret is set,PUT
requests 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
.