6. Active Storage facilitates uploading files to a cloud storage service like
Amazon S3, Google Cloud Storage, or Microsoft Azure Storage and
attaching those files to Active Record objects. It comes with a local disk-
based service for development and testing and supports mirroring files to
subordinate services for backups and migrations.
8. rails active_storage:install
It creates to tables in database:
● active_storage_blobs ( contains all metadata of file uploaded )
● active_storage_attachments ( join table between model and uploads which we create)
24. To check it from console
config/environments/production.rb
If upgrading from older version then add following line to
production.rb
25. For Production applications
● Make sure you add master.key file in .gitignore
(You can add actual key on server where you are deploying application
instead of directly committing it to git or any version control system)
● ENV[RAILS_MASTER_KEY]
(If you are using any continuous integration tool then you can add it there as
environment variable)
26. You can use EncryptedConfiguration through Rails.application.encrypted. Let's
say you want to encrypt some data and save the encrypted file on
top_secret.txt.enc.
encrypted = Rails.application.encrypted("top_secret.txt.enc")
This will create a new EncryptedConfiguration object which you can use to
encrypt and decrypt text.
encrypted.write("This is a top secret message.")
If you check the file top_secret.txt.enc, you will see :
EprXfkUXq/rlKQUTPg52OMoSUWfYnPHCiYqxd9y/URvVebmmuhap--QFtMHoVUYleOY8qC--
xadtJ2aVQJ2y0IDljt9yAg==
27. If you want to use a different key aside from config/master.key, create one by
running
ActiveSupport::EncryptedConfiguration.generate_key
o/p - 0dbcb53a3e52e6b983bd75d932dca52c
Save the key to a file. If you use config/top_secret.key as the file name, you can
get the EncryptedConfiguration object with
encrypted = Rails.application.encrypted("top_secret.txt.enc", key_path:
"config/top_secret.key")
28. Redis cache store
Rails 5.2 introduced built-in Redis cache store, which allows you to store cache
entries in Redis.
Add below line to environment file. (e.g config/environments/production.rb)
Config.cache_store = :redis_cache_store
In Rails 5.2, write_multi was added . Each cache store can implement this
method and provide the functionality to add multiple entries at once.
29. HTTP2/ Early hints
Early Hints is a new HTTP status code that allows your application to send links to assets
that you would like to load early. For example if you have a stylesheet and javascript file
included in your Rails application you may want to tell the client about them early so it can
start downloading them.
Check this blog post to know more about this feature.