This is a little rails project to get you started with Active Storage. Storage hosts are pre-configured.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
Clone the repository on your machine with the following commands.
With HTTPS
git clone https://github.com/Duckiduc/active-storage.git
With SSH (recommanded)
git clone [email protected]:Duckiduc/active-storage.git
Have Ruby installed on your machine.
Step by step installation
Install a bundler
gem install bundler
Install the latest rails
bundle install rails
Install the dependencies / GEM
bundle install
Run the command rails s
to start the server.
You need to uncomment the service you want to use and update the credentials
#config/storage.yml
amazon:
service: S3
access_key_id: XXXXXXXXXXXXXXXX
secret_access_key: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
region: region
bucket: bucket_name
#config/environments/development.rb
config.active_storage.service = :amazon
#config/environments/production.rb
config.active_storage.service = :amazon
#config/storage.yml
google:
service: GCS
project: project_name
credentials: XXXXXXXXXXXXXXXX
bucket: bucket-name
#config/environments/development.rb
config.active_storage.service = :google
#config/environments/production.rb
config.active_storage.service = :google
#config/storage.yml
microsoft:
service: AzureStorage
storage_account_name: account_name
storage_access_key: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
container: container-name
#config/environments/development.rb
config.active_storage.service = :microsoft
#config/environments/production.rb
config.active_storage.service = :microsoft
#config/storage.yml
mirror:
service: Mirror
primary: service_name
mirrors:
- service_name
service_name
being the service you want to use (amazon
,microsoft
)You can use multiple mirros at once
mirrors - amazon - google - microsoft
#config/environments/development.rb
config.active_storage.service = :mirror
#config/environments/production.rb
config.active_storage.service = :mirror
Note that your credentials are not encrypted.
Make sure you set your source service as the primary service and your target(s) as mirrors
In the terminal, run the command rake active_storage:mirror_all
- Ruby — Interpreted, high-level, general-purpose programming language
- Rails - Server-side web application framework
- HTML5 — Markup language
- CSS3 — Style sheet language
- SCSS - Style sheet language
- JavaScript — Programming language that conforms to the ECMAScript specs
Rails version used: 6.0.3.3
Ruby version: ruby 2.7.1p83
We use the Github for versioning.
- Duc-Thomas Nguyen - Initial work - LinkedIn