Move cw_to_activestorage generator to houdini_upgrade

This commit is contained in:
Eric 2020-05-01 16:36:06 -05:00
parent d965c1a988
commit d75fb9b135
22 changed files with 17 additions and 7 deletions

View file

@ -1,11 +1,9 @@
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
class CwToActivestorageGenerator < Rails::Generators::Base
source_root File.expand_path('templates', __dir__)
class_option :aws_bucket, type: :string, required: true
class_option :aws_assethost, type: :string, required: false
def install_activestorage_tables
rake 'active_storage:install'
end
def copy_uploaders
if (!File.exists?('app/uploaders'))
directory 'uploaders', 'app/uploaders'
@ -40,4 +38,11 @@ class CwToActivestorageGenerator < Rails::Generators::Base
gem "carrierwave", "~> 1"
gem "carrierwave-aws"
end
def add_carrierwave_template
@aws_bucket = options[:aws_bucket]
@aws_assethost = options[:aws_assethost] || "https://#{@aws_bucket}.s3.amazonaws.com"
template 'initializers/carrierwave.rb', 'config/initializers/carrierwave.rb'
end
end

View file

@ -4,9 +4,9 @@
CarrierWave.configure do |config|
config.storage = :aws
config.aws_bucket = ENV['CARRIERWAVE_AWS_BUCKET']
config.aws_bucket = <%= @aws_bucket %>
config.aws_acl = :public_read
config.asset_host = ENV['CARRIERWAVE_IMAGE_HOST'] || "https://#{config.aws_bucket}.s3.amazonaws.com"
config.asset_host = <%= @aws_assethost %>
# config.aws_authenticated_url_expiration = 60 * 60 * 24 * 365
# config.aws_credentials = {
# access_key_id: ENV['CARRIERWAVE_AWS_ACCESS_KEY_ID'],

View file

@ -7,10 +7,15 @@
task :run => :environment do
Rake::Task["houdini_upgrade:install:migrations"].invoke
Rake::Task["active_storage:install"].invoke
Rake::Task["houdini_upgrade:cw_to_activestorage"].invoke
Rake::Task["houdini_upgrade:run_db_migration"].invoke
end
task :run_db_migration do
task :migration do
sh 'rails db:migrate'
end
task :cw_to_activestorage do
sh 'rails generate cw_to_activestorage'
end
end