Class: Boring::ActiveStorage::Aws::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Boring::ActiveStorage::Aws::InstallGenerator
- Defined in:
- lib/generators/boring/active_storage/aws/install/install_generator.rb
Instance Method Summary collapse
- #add_active_storage ⇒ Object
- #add_aws_storage_configuration ⇒ Object
- #add_aws_to_the_application ⇒ Object
- #add_configuration_to_production ⇒ Object
Instance Method Details
#add_active_storage ⇒ Object
10 11 12 13 14 15 |
# File 'lib/generators/boring/active_storage/aws/install/install_generator.rb', line 10 def add_active_storage unless [:skip_active_storage] say "Adding ActiveStorage", :green run "bin/rails active_storage:install" end end |
#add_aws_storage_configuration ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/generators/boring/active_storage/aws/install/install_generator.rb', line 36 def add_aws_storage_configuration aws_storage_config_content = " amazon:\n service: S3\n access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %>\n secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %>\n region: us-east-1\n bucket: your_own_bucket\n RUBY\n append_to_file \"config/storage.yml\", aws_storage_config_content\nend\n" |
#add_aws_to_the_application ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/generators/boring/active_storage/aws/install/install_generator.rb', line 17 def add_aws_to_the_application Bundler.with_unbundled_env do say "Adding AWS gem", :green aws_gem_content = " \\n\n # for AWS Service\n gem \"aws-sdk-s3\", require: false\n RUBY\n append_to_file \"Gemfile\", aws_gem_content\n run \"bundle install\"\n end\nend\n" |
#add_configuration_to_production ⇒ Object
30 31 32 33 34 |
# File 'lib/generators/boring/active_storage/aws/install/install_generator.rb', line 30 def add_configuration_to_production gsub_file "config/environments/production.rb", "config.active_storage.service = :local", "config.active_storage.service = :amazon" end |