Add CarrierWave Backgrounder

This commit is contained in:
Dominik M. Kwiatek 2020-05-17 19:58:27 +01:00
parent 5c0871f33c
commit d185c54f03
7 changed files with 22 additions and 5 deletions

View File

@ -38,6 +38,7 @@ gem 'tiny-color-rails'
gem 'jquery-minicolors-rails' gem 'jquery-minicolors-rails'
gem 'colorize' gem 'colorize'
gem 'carrierwave', '~> 2.0' gem 'carrierwave', '~> 2.0'
gem 'carrierwave_backgrounder', git: 'https://github.com/mltnhm/carrierwave_backgrounder.git'
gem 'mini_magick' gem 'mini_magick'
gem "rolify", "~> 5.2" gem "rolify", "~> 5.2"

View File

@ -10,6 +10,14 @@ GIT
oauth oauth
simple_oauth simple_oauth
GIT
remote: https://github.com/mltnhm/carrierwave_backgrounder.git
revision: 8fe468957f047ad7039f07679e5952a534d07b6d
specs:
carrierwave_backgrounder (0.4.2)
carrierwave (>= 0.5, <= 2.1)
mime-types (>= 3.0.0)
GIT GIT
remote: https://github.com/retrospring/questiongenerator.git remote: https://github.com/retrospring/questiongenerator.git
revision: c5f8362ff769425d42a94b3a611731eadaa5e0ca revision: c5f8362ff769425d42a94b3a611731eadaa5e0ca
@ -527,6 +535,7 @@ DEPENDENCIES
byebug byebug
capybara capybara
carrierwave (~> 2.0) carrierwave (~> 2.0)
carrierwave_backgrounder!
coffee-rails (~> 4.1) coffee-rails (~> 4.1)
colorize colorize
database_cleaner database_cleaner

View File

@ -58,7 +58,9 @@ class User < ApplicationRecord
validates :bio, length: { maximum: 200 } validates :bio, length: { maximum: 200 }
mount_uploader :profile_picture, ProfilePictureUploader, mount_on: :profile_picture_file_name mount_uploader :profile_picture, ProfilePictureUploader, mount_on: :profile_picture_file_name
process_in_background :profile_picture
mount_uploader :profile_header, ProfileHeaderUploader, mount_on: :profile_header_file_name mount_uploader :profile_header, ProfileHeaderUploader, mount_on: :profile_header_file_name
process_in_background :profile_header
before_save do before_save do
self.website = if website.match %r{\Ahttps?://} self.website = if website.match %r{\Ahttps?://}

View File

@ -1,6 +1,7 @@
class BaseUploader < CarrierWave::Uploader::Base class BaseUploader < CarrierWave::Uploader::Base
include CarrierWave::Compatibility::Paperclip include CarrierWave::Compatibility::Paperclip
include CarrierWave::MiniMagick include CarrierWave::MiniMagick
include CarrierWave::Backgrounder::Delay
storage :fog storage :fog

View File

@ -9,4 +9,8 @@ CarrierWave.configure do |config|
config.fog_credentials = APP_CONFIG.dig("fog", "credentials") unless APP_CONFIG.dig("fog", "credentials").nil? config.fog_credentials = APP_CONFIG.dig("fog", "credentials") unless APP_CONFIG.dig("fog", "credentials").nil?
config.fog_directory = APP_CONFIG.dig("fog", "directory") unless APP_CONFIG.dig("fog", "directory").nil? config.fog_directory = APP_CONFIG.dig("fog", "directory") unless APP_CONFIG.dig("fog", "directory").nil?
end end
end end
CarrierWave::Backgrounder.configure do |c|
c.backend :sidekiq, queue: :carrierwave
end

View File

@ -7,7 +7,7 @@ production:
:concurrency: 25 :concurrency: 25
:queues: :queues:
- share - share
- paperclip - carrierwave
- mailers - mailers
- deletion - deletion
- question - question

View File

@ -10,7 +10,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2020_05_13_154602) do ActiveRecord::Schema.define(version: 2020_05_09_094402) do
# These are extensions that must be enabled in order to support this database # These are extensions that must be enabled in order to support this database
enable_extension "plpgsql" enable_extension "plpgsql"
@ -250,7 +250,7 @@ ActiveRecord::Schema.define(version: 2020_05_13_154602) do
t.text "bio", default: "", null: false t.text "bio", default: "", null: false
t.string "profile_picture_file_name" t.string "profile_picture_file_name"
t.string "profile_picture_content_type" t.string "profile_picture_content_type"
t.bigint "profile_picture_file_size" t.integer "profile_picture_file_size"
t.datetime "profile_picture_updated_at" t.datetime "profile_picture_updated_at"
t.boolean "profile_picture_processing" t.boolean "profile_picture_processing"
t.integer "crop_x" t.integer "crop_x"
@ -267,7 +267,7 @@ ActiveRecord::Schema.define(version: 2020_05_13_154602) do
t.integer "comment_smiled_count", default: 0, null: false t.integer "comment_smiled_count", default: 0, null: false
t.string "profile_header_file_name" t.string "profile_header_file_name"
t.string "profile_header_content_type" t.string "profile_header_content_type"
t.bigint "profile_header_file_size" t.integer "profile_header_file_size"
t.datetime "profile_header_updated_at" t.datetime "profile_header_updated_at"
t.boolean "profile_header_processing" t.boolean "profile_header_processing"
t.integer "crop_h_x" t.integer "crop_h_x"