Remove uploaded fields from models
This commit is contained in:
parent
93931caf98
commit
8c997b6488
17 changed files with 14 additions and 620 deletions
|
@ -50,9 +50,9 @@ class Campaign < ApplicationRecord
|
|||
|
||||
attr_accessor :goal_amount_dollars
|
||||
|
||||
mount_uploader :main_image, CampaignMainImageUploader
|
||||
mount_uploader :background_image, CampaignBackgroundImageUploader
|
||||
mount_uploader :banner_image, CampaignBannerImageUploader
|
||||
has_one_attached :main_image
|
||||
has_one_attached :background_image
|
||||
has_one_attached :banner_image
|
||||
|
||||
has_many :donations
|
||||
has_many :charges, through: :donations
|
||||
|
|
|
@ -61,9 +61,9 @@ class Event < ApplicationRecord
|
|||
geocoded_by :full_address
|
||||
|
||||
accepts_nested_attributes_for :ticket_levels, allow_destroy: true
|
||||
|
||||
mount_uploader :main_image, EventMainImageUploader
|
||||
mount_uploader :background_image, EventBackgroundImageUploader
|
||||
has_one_attached :main_image
|
||||
has_one_attached :background_image
|
||||
|
||||
|
||||
scope :not_deleted, -> { where(deleted: [nil, false]) }
|
||||
scope :deleted, -> { where(deleted: true) }
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
class ImageAttachment < ApplicationRecord
|
||||
# :parent_id,
|
||||
# :file
|
||||
mount_uploader :file, ImageAttachmentUploader
|
||||
has_one_attached :file
|
||||
|
||||
# not sure if poly parent is used on this model, as all values are nil in db
|
||||
belongs_to :parent, polymorphic: true
|
||||
|
|
|
@ -97,12 +97,12 @@ class Nonprofit < ApplicationRecord
|
|||
scope :identity_verified, -> { where(verification_status: 'verified') }
|
||||
scope :published, -> { where(published: true) }
|
||||
|
||||
mount_uploader :main_image, NonprofitUploader
|
||||
mount_uploader :second_image, NonprofitUploader
|
||||
mount_uploader :third_image, NonprofitUploader
|
||||
mount_uploader :background_image, NonprofitBackgroundUploader
|
||||
mount_uploader :logo, NonprofitLogoUploader
|
||||
|
||||
has_one_attached :main_image
|
||||
has_one_attached :second_image
|
||||
has_one_attached :third_image
|
||||
has_one_attached :background_image
|
||||
has_one_attached :logo
|
||||
|
||||
serialize :achievements, Array
|
||||
serialize :categories, Array
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ class Profile < ApplicationRecord
|
|||
|
||||
serialize :privacy_settings, Array
|
||||
|
||||
mount_uploader :picture, ProfileUploader
|
||||
has_one_attached :picture
|
||||
|
||||
belongs_to :user
|
||||
has_many :activities # Activities this profile has created
|
||||
|
|
|
@ -1,54 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||
# encoding: utf-8
|
||||
|
||||
class ArticleBackgroundUploader < CarrierWave::Uploader::Base
|
||||
# Include RMagick or MiniMagick support:
|
||||
# include CarrierWave::RMagick
|
||||
include CarrierWave::MiniMagick
|
||||
|
||||
# Include the Sprockets helpers for Rails 3.1+ asset pipeline compatibility:
|
||||
# include Sprockets::Helpers::RailsHelper
|
||||
# include Sprockets::Helpers::IsolatedHelper
|
||||
|
||||
# Override the directory where uploaded files will be stored.
|
||||
# This is a sensible default for uploaders that are meant to be mounted:
|
||||
def store_dir
|
||||
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
|
||||
end
|
||||
|
||||
# Provide a default URL as a default if there hasn't been a file uploaded:
|
||||
def default_url
|
||||
# For Rails 3.1+ asset pipeline compatibility:
|
||||
Image::DefaultNonprofitUrl
|
||||
end
|
||||
|
||||
# Process files as they are uploaded:
|
||||
# process :scale => [200, 300]
|
||||
#
|
||||
# def scale(width, height)
|
||||
# # do something
|
||||
# end
|
||||
|
||||
# Create different versions of your uploaded files:
|
||||
version :large do
|
||||
process resize_to_fill: [600, 400]
|
||||
end
|
||||
|
||||
# Add a white list of extensions which are allowed to be uploaded.
|
||||
# For images you might use something like this:
|
||||
def extension_white_list
|
||||
%w[jpg jpeg png]
|
||||
end
|
||||
|
||||
# Override the filename of the uploaded files:
|
||||
# Avoid using model.id or version_name here, see uploader/store.rb for details.
|
||||
# def filename
|
||||
# "something.jpg" if original_filename
|
||||
# end
|
||||
|
||||
def cache_dir
|
||||
"#{Rails.root}/tmp/uploads"
|
||||
end
|
||||
end
|
|
@ -1,54 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||
# encoding: utf-8
|
||||
|
||||
class ArticleUploader < CarrierWave::Uploader::Base
|
||||
# Include RMagick or MiniMagick support:
|
||||
# include CarrierWave::RMagick
|
||||
include CarrierWave::MiniMagick
|
||||
|
||||
# Include the Sprockets helpers for Rails 3.1+ asset pipeline compatibility:
|
||||
# include Sprockets::Helpers::RailsHelper
|
||||
# include Sprockets::Helpers::IsolatedHelper
|
||||
|
||||
# Override the directory where uploaded files will be stored.
|
||||
# This is a sensible default for uploaders that are meant to be mounted:
|
||||
def store_dir
|
||||
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
|
||||
end
|
||||
|
||||
# Provide a default URL as a default if there hasn't been a file uploaded:
|
||||
def default_url
|
||||
# For Rails 3.1+ asset pipeline compatibility:
|
||||
Image::DefaultNonprofitUrl
|
||||
end
|
||||
|
||||
# Process files as they are uploaded:
|
||||
# process :scale => [200, 300]
|
||||
#
|
||||
# def scale(width, height)
|
||||
# # do something
|
||||
# end
|
||||
|
||||
# Create different versions of your uploaded files:
|
||||
version :thumb do
|
||||
process resize_to_fill: [200, 200]
|
||||
end
|
||||
|
||||
# Add a white list of extensions which are allowed to be uploaded.
|
||||
# For images you might use something like this:
|
||||
def extension_white_list
|
||||
%w[jpg jpeg png]
|
||||
end
|
||||
|
||||
# Override the filename of the uploaded files:
|
||||
# Avoid using model.id or version_name here, see uploader/store.rb for details.
|
||||
# def filename
|
||||
# "something.jpg" if original_filename
|
||||
# end
|
||||
|
||||
def cache_dir
|
||||
"#{Rails.root}/tmp/uploads"
|
||||
end
|
||||
end
|
|
@ -1,25 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||
# encoding: utf-8
|
||||
|
||||
class CampaignBackgroundImageUploader < CarrierWave::Uploader::Base
|
||||
include CarrierWave::MiniMagick
|
||||
|
||||
def store_dir
|
||||
"uploads/campaigns/#{mounted_as}/#{model.id}"
|
||||
end
|
||||
|
||||
# Create different versions of your uploaded files:
|
||||
version :normal do
|
||||
process resize_to_fill: [1000, 600]
|
||||
end
|
||||
|
||||
def extension_white_list
|
||||
%w[jpg jpeg png]
|
||||
end
|
||||
|
||||
def cache_dir
|
||||
"#{Rails.root}/tmp/uploads"
|
||||
end
|
||||
end
|
|
@ -1,18 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||
class CampaignBannerImageUploader < CarrierWave::Uploader::Base
|
||||
include CarrierWave::MiniMagick
|
||||
|
||||
def store_dir
|
||||
"uploads/campaigns/#{mounted_as}/#{model.id}"
|
||||
end
|
||||
|
||||
def extension_white_list
|
||||
%w[jpg jpeg png]
|
||||
end
|
||||
|
||||
def cache_dir
|
||||
"#{Rails.root}/tmp/uploads"
|
||||
end
|
||||
end
|
|
@ -1,56 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||
class CampaignMainImageUploader < CarrierWave::Uploader::Base
|
||||
# Include RMagick or MiniMagick support:
|
||||
# include CarrierWave::RMagick
|
||||
include CarrierWave::MiniMagick
|
||||
|
||||
# Include the Sprockets helpers for Rails 3.1+ asset pipeline compatibility:
|
||||
# include Sprockets::Helpers::RailsHelper
|
||||
# include Sprockets::Helpers::IsolatedHelper
|
||||
|
||||
# Override the directory where uploaded files will be stored.
|
||||
# This is a sensible default for uploaders that are meant to be mounted:
|
||||
def store_dir
|
||||
"uploads/campaigns/#{mounted_as}/#{model.id}"
|
||||
end
|
||||
|
||||
# Provide a default URL as a default if there hasn't been a file uploaded:
|
||||
def default_url
|
||||
# For Rails 3.1+ asset pipeline compatibility:
|
||||
Image::DefaultProfileUrl
|
||||
end
|
||||
|
||||
# Process files as they are uploaded:
|
||||
# process :scale => [200, 300]
|
||||
#
|
||||
# def scale(width, height)
|
||||
# # do something
|
||||
# end
|
||||
|
||||
# Create different versions of your uploaded files:
|
||||
version :normal do
|
||||
process resize_to_fill: [524, 360]
|
||||
end
|
||||
|
||||
version :thumb do
|
||||
process resize_to_fill: [180, 150]
|
||||
end
|
||||
|
||||
# Add a white list of extensions which are allowed to be uploaded.
|
||||
# For images you might use something like this:
|
||||
def extension_white_list
|
||||
%w[jpg jpeg png]
|
||||
end
|
||||
|
||||
# Override the filename of the uploaded files:
|
||||
# Avoid using model.id or version_name here, see uploader/store.rb for details.
|
||||
# def filename
|
||||
# "something.jpg" if original_filename
|
||||
# end
|
||||
|
||||
def cache_dir
|
||||
"#{Rails.root}/tmp/uploads"
|
||||
end
|
||||
end
|
|
@ -1,52 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||
class EventBackgroundImageUploader < CarrierWave::Uploader::Base
|
||||
# Include RMagick or MiniMagick support:
|
||||
# include CarrierWave::RMagick
|
||||
include CarrierWave::MiniMagick
|
||||
|
||||
# Include the Sprockets helpers for Rails 3.1+ asset pipeline compatibility:
|
||||
# include Sprockets::Helpers::RailsHelper
|
||||
# include Sprockets::Helpers::IsolatedHelper
|
||||
|
||||
# Override the directory where uploaded files will be stored.
|
||||
# This is a sensible default for uploaders that are meant to be mounted:
|
||||
def store_dir
|
||||
"uploads/events/#{mounted_as}/#{model.id}"
|
||||
end
|
||||
|
||||
# Provide a default URL as a default if there hasn't been a file uploaded:
|
||||
def default_url
|
||||
# For Rails 3.1+ asset pipeline compatibility:
|
||||
Image::DefaultCampaignUrl
|
||||
end
|
||||
|
||||
# Process files as they are uploaded:
|
||||
# process :scale => [200, 300]
|
||||
#
|
||||
# def scale(width, height)
|
||||
# # do something
|
||||
# end
|
||||
|
||||
# Create different versions of your uploaded files:
|
||||
version :normal do
|
||||
process resize_to_fill: [1000, 600]
|
||||
end
|
||||
|
||||
# Add a white list of extensions which are allowed to be uploaded.
|
||||
# For images you might use something like this:
|
||||
def extension_white_list
|
||||
%w[jpg jpeg png]
|
||||
end
|
||||
|
||||
# Override the filename of the uploaded files:
|
||||
# Avoid using model.id or version_name here, see uploader/store.rb for details.
|
||||
# def filename
|
||||
# "something.jpg" if original_filename
|
||||
# end
|
||||
|
||||
def cache_dir
|
||||
"#{Rails.root}/tmp/uploads"
|
||||
end
|
||||
end
|
|
@ -1,56 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||
class EventMainImageUploader < CarrierWave::Uploader::Base
|
||||
# Include RMagick or MiniMagick support:
|
||||
# include CarrierWave::RMagick
|
||||
include CarrierWave::MiniMagick
|
||||
|
||||
# Include the Sprockets helpers for Rails 3.1+ asset pipeline compatibility:
|
||||
# include Sprockets::Helpers::RailsHelper
|
||||
# include Sprockets::Helpers::IsolatedHelper
|
||||
|
||||
# Override the directory where uploaded files will be stored.
|
||||
# This is a sensible default for uploaders that are meant to be mounted:
|
||||
def store_dir
|
||||
"uploads/events/#{mounted_as}/#{model.id}"
|
||||
end
|
||||
|
||||
# Provide a default URL as a default if there hasn't been a file uploaded:
|
||||
def default_url
|
||||
# For Rails 3.1+ asset pipeline compatibility:
|
||||
Image::DefaultProfileUrl
|
||||
end
|
||||
|
||||
# Process files as they are uploaded:
|
||||
# process :scale => [200, 300]
|
||||
#
|
||||
# def scale(width, height)
|
||||
# # do something
|
||||
# end
|
||||
|
||||
# Create different versions of your uploaded files:
|
||||
version :normal do
|
||||
process resize_to_fill: [400, 400]
|
||||
end
|
||||
|
||||
version :thumb do
|
||||
process resize_to_fill: [100, 100]
|
||||
end
|
||||
|
||||
# Add a white list of extensions which are allowed to be uploaded.
|
||||
# For images you might use something like this:
|
||||
def extension_white_list
|
||||
%w[jpg jpeg png]
|
||||
end
|
||||
|
||||
# Override the filename of the uploaded files:
|
||||
# Avoid using model.id or version_name here, see uploader/store.rb for details.
|
||||
# def filename
|
||||
# "something.jpg" if original_filename
|
||||
# end
|
||||
|
||||
def cache_dir
|
||||
"#{Rails.root}/tmp/uploads"
|
||||
end
|
||||
end
|
|
@ -1,64 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||
# encoding: utf-8
|
||||
|
||||
class ImageAttachmentUploader < CarrierWave::Uploader::Base
|
||||
# Include RMagick or MiniMagick support:
|
||||
# include CarrierWave::RMagick
|
||||
include CarrierWave::MiniMagick
|
||||
|
||||
# Include the Sprockets helpers for Rails 3.1+ asset pipeline compatibility:
|
||||
# include Sprockets::Helpers::RailsHelper
|
||||
# include Sprockets::Helpers::IsolatedHelper
|
||||
|
||||
# Override the directory where uploaded files will be stored.
|
||||
# This is a sensible default for uploaders that are meant to be mounted:
|
||||
def store_dir
|
||||
"uploads/image_attachments/#{mounted_as}/#{model.id}"
|
||||
end
|
||||
|
||||
# Provide a default URL as a default if there hasn't been a file uploaded:
|
||||
def default_url
|
||||
# For Rails 3.1+ asset pipeline compatibility:
|
||||
Image::DefaultProfileUrl
|
||||
end
|
||||
|
||||
# Process files as they are uploaded:
|
||||
# process :scale => [200, 300]
|
||||
#
|
||||
# def scale(width, height)
|
||||
# # do something
|
||||
# end
|
||||
|
||||
# Create different versions of your uploaded files:
|
||||
version :large do
|
||||
process resize_to_fill: [600, 400]
|
||||
end
|
||||
version :medium do
|
||||
process resize_to_fill: [400, 266]
|
||||
end
|
||||
version :small do
|
||||
process resize_to_fill: [400, 266]
|
||||
end
|
||||
# slightly smaller than the normal thumb
|
||||
version :thumb_explore do
|
||||
process resize_to_fill: [200, 133]
|
||||
end
|
||||
|
||||
# Add a white list of extensions which are allowed to be uploaded.
|
||||
# For images you might use something like this:
|
||||
def extension_white_list
|
||||
%w[jpg jpeg png]
|
||||
end
|
||||
|
||||
# Override the filename of the uploaded files:
|
||||
# Avoid using model.id or version_name here, see uploader/store.rb for details.
|
||||
# def filename
|
||||
# "something.jpg" if original_filename
|
||||
# end
|
||||
|
||||
def cache_dir
|
||||
"#{Rails.root}/tmp/uploads"
|
||||
end
|
||||
end
|
|
@ -1,55 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||
|
||||
# encoding: utf-8
|
||||
|
||||
class NonprofitBackgroundUploader < CarrierWave::Uploader::Base
|
||||
# Include RMagick or MiniMagick support:
|
||||
# include CarrierWave::RMagick
|
||||
include CarrierWave::MiniMagick
|
||||
|
||||
# Include the Sprockets helpers for Rails 3.1+ asset pipeline compatibility:
|
||||
# include Sprockets::Helpers::RailsHelper
|
||||
# include Sprockets::Helpers::IsolatedHelper
|
||||
|
||||
# Override the directory where uploaded files will be stored.
|
||||
# This is a sensible default for uploaders that are meant to be mounted:
|
||||
def store_dir
|
||||
"uploads/npo/#{mounted_as}/#{model.id}"
|
||||
end
|
||||
|
||||
# Provide a default URL as a default if there hasn't been a file uploaded:
|
||||
def default_url
|
||||
# For Rails 3.1+ asset pipeline compatibility:
|
||||
Image::DefaultNonprofitUrl
|
||||
end
|
||||
|
||||
# Process files as they are uploaded:
|
||||
# process :scale => [200, 300]
|
||||
#
|
||||
# def scale(width, height)
|
||||
# # do something
|
||||
# end
|
||||
|
||||
# Create different versions of your uploaded files:
|
||||
version :normal do
|
||||
process resize_to_fill: [1000, 600]
|
||||
end
|
||||
|
||||
# Add a white list of extensions which are allowed to be uploaded.
|
||||
# For images you might use something like this:
|
||||
def extension_white_list
|
||||
%w[jpg jpeg png]
|
||||
end
|
||||
|
||||
# Override the filename of the uploaded files:
|
||||
# Avoid using model.id or version_name here, see uploader/store.rb for details.
|
||||
# def filename
|
||||
# "something.jpg" if original_filename
|
||||
# end
|
||||
|
||||
def cache_dir
|
||||
"#{Rails.root}/tmp/uploads"
|
||||
end
|
||||
end
|
|
@ -1,51 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||
# encoding: utf-8
|
||||
|
||||
class NonprofitLogoUploader < CarrierWave::Uploader::Base
|
||||
# Include RMagick or MiniMagick support:
|
||||
# include CarrierWave::RMagick
|
||||
include CarrierWave::MiniMagick
|
||||
|
||||
# Include the Sprockets helpers for Rails 3.1+ asset pipeline compatibility:
|
||||
# include Sprockets::Helpers::RailsHelper
|
||||
# include Sprockets::Helpers::IsolatedHelper
|
||||
|
||||
# Override the directory where uploaded files will be stored.
|
||||
# This is a sensible default for uploaders that are meant to be mounted:
|
||||
def store_dir
|
||||
"uploads/npo/#{mounted_as}/#{model.id}"
|
||||
end
|
||||
|
||||
# Provide a default URL as a default if there hasn't been a file uploaded:
|
||||
def default_url
|
||||
# For Rails 3.1+ asset pipeline compatibility:
|
||||
Image::DefaultProfileUrl
|
||||
end
|
||||
|
||||
# Create different versions of your uploaded files:
|
||||
version :large do
|
||||
process resize_to_fit: [180, 180]
|
||||
end
|
||||
version :normal do
|
||||
process resize_to_fit: [100, 100]
|
||||
end
|
||||
version :small do
|
||||
process resize_to_fit: [30, 30]
|
||||
end
|
||||
|
||||
def extension_white_list
|
||||
%w[jpg jpeg png gif]
|
||||
end
|
||||
|
||||
# Override the filename of the uploaded files:
|
||||
# Avoid using model.id or version_name here, see uploader/store.rb for details.
|
||||
# def filename
|
||||
# "something.jpg" if original_filename
|
||||
# end
|
||||
|
||||
def cache_dir
|
||||
"#{Rails.root}/tmp/uploads"
|
||||
end
|
||||
end
|
|
@ -1,61 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||
# encoding: utf-8
|
||||
|
||||
class NonprofitUploader < CarrierWave::Uploader::Base
|
||||
# Include RMagick or MiniMagick support:
|
||||
# include CarrierWave::RMagick
|
||||
include CarrierWave::MiniMagick
|
||||
|
||||
# Include the Sprockets helpers for Rails 3.1+ asset pipeline compatibility:
|
||||
# include Sprockets::Helpers::RailsHelper
|
||||
# include Sprockets::Helpers::IsolatedHelper
|
||||
|
||||
# Override the directory where uploaded files will be stored.
|
||||
# This is a sensible default for uploaders that are meant to be mounted:
|
||||
def store_dir
|
||||
"uploads/npo/#{mounted_as}/#{model.id}"
|
||||
end
|
||||
|
||||
# Provide a default URL as a default if there hasn't been a file uploaded:
|
||||
def default_url
|
||||
# For Rails 3.1+ asset pipeline compatibility:
|
||||
Image::DefaultProfileUrl
|
||||
end
|
||||
|
||||
# Process files as they are uploaded:
|
||||
# process :scale => [200, 300]
|
||||
#
|
||||
# def scale(width, height)
|
||||
# # do something
|
||||
# end
|
||||
|
||||
# Create different versions of your uploaded files:
|
||||
version :nonprofit_carousel do
|
||||
process resize_to_fill: [590, 338]
|
||||
end
|
||||
version :thumb do
|
||||
process resize_to_fill: [188, 120]
|
||||
end
|
||||
# slightly smaller than the normal thumb
|
||||
version :thumb_explore do
|
||||
process resize_to_fill: [100, 100]
|
||||
end
|
||||
|
||||
# Add a white list of extensions which are allowed to be uploaded.
|
||||
# For images you might use something like this:
|
||||
def extension_white_list
|
||||
%w[jpg jpeg png]
|
||||
end
|
||||
|
||||
# Override the filename of the uploaded files:
|
||||
# Avoid using model.id or version_name here, see uploader/store.rb for details.
|
||||
# def filename
|
||||
# "something.jpg" if original_filename
|
||||
# end
|
||||
|
||||
def cache_dir
|
||||
"#{Rails.root}/tmp/uploads"
|
||||
end
|
||||
end
|
|
@ -1,60 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||
# encoding: utf-8
|
||||
|
||||
class ProfileUploader < CarrierWave::Uploader::Base
|
||||
# Include RMagick or MiniMagick support:
|
||||
# include CarrierWave::RMagick
|
||||
include CarrierWave::MiniMagick
|
||||
|
||||
# Include the Sprockets helpers for Rails 3.1+ asset pipeline compatibility:
|
||||
# include Sprockets::Helpers::RailsHelper
|
||||
# include Sprockets::Helpers::IsolatedHelper
|
||||
|
||||
# Override the directory where uploaded files will be stored.
|
||||
# This is a sensible default for uploaders that are meant to be mounted:
|
||||
def store_dir
|
||||
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
|
||||
end
|
||||
|
||||
# Provide a default URL as a default if there hasn't been a file uploaded:
|
||||
def default_url
|
||||
# For Rails 3.1+ asset pipeline compatibility:
|
||||
Image::DefaultProfileUrl
|
||||
end
|
||||
|
||||
# Process files as they are uploaded:
|
||||
# process :scale => [200, 300]
|
||||
#
|
||||
# def scale(width, height)
|
||||
# # do something
|
||||
# end
|
||||
|
||||
# Create different versions of your uploaded files:
|
||||
version :normal do
|
||||
process resize_to_fill: [150, 150]
|
||||
end
|
||||
version :medium do
|
||||
process resize_to_fill: [100, 100]
|
||||
end
|
||||
version :tiny do
|
||||
process resize_to_fill: [50, 50]
|
||||
end
|
||||
|
||||
# Add a white list of extensions which are allowed to be uploaded.
|
||||
# For images you might use something like this:
|
||||
def extension_white_list
|
||||
%w[jpg jpeg png]
|
||||
end
|
||||
|
||||
# Override the filename of the uploaded files:
|
||||
# Avoid using model.id or version_name here, see uploader/store.rb for details.
|
||||
# def filename
|
||||
# "something.jpg" if original_filename
|
||||
# end
|
||||
|
||||
def cache_dir
|
||||
"#{Rails.root}/tmp/uploads"
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue