Create default image attachments for all models
This commit is contained in:
parent
60eb01c2ee
commit
2e0a3a6c03
4 changed files with 22 additions and 1 deletions
|
@ -58,6 +58,9 @@ class Campaign < ApplicationRecord
|
||||||
has_one_attached_with_sizes(:main_image, {normal: [524, 360], thumb: [180,150]})
|
has_one_attached_with_sizes(:main_image, {normal: [524, 360], thumb: [180,150]})
|
||||||
has_one_attached_with_sizes(:background_image, {normal: [1000, 600]})
|
has_one_attached_with_sizes(:background_image, {normal: [1000, 600]})
|
||||||
|
|
||||||
|
has_one_attached_with_default(:main_image, Image::DefaultProfileUrl,
|
||||||
|
filename: "main_image_#{SecureRandom.uuid}#{Pathname.new(Image::DefaultProfileUrl).extname}")
|
||||||
|
|
||||||
has_many :donations
|
has_many :donations
|
||||||
has_many :charges, through: :donations
|
has_many :charges, through: :donations
|
||||||
has_many :payments, through: :donations, source: 'payment'
|
has_many :payments, through: :donations, source: 'payment'
|
||||||
|
|
|
@ -67,6 +67,12 @@ class Event < ApplicationRecord
|
||||||
|
|
||||||
has_one_attached_with_sizes :main_image, {normal: 400, thumb: 100}
|
has_one_attached_with_sizes :main_image, {normal: 400, thumb: 100}
|
||||||
has_one_attached_with_sizes :background_image, {normal: [1000, 600]}
|
has_one_attached_with_sizes :background_image, {normal: [1000, 600]}
|
||||||
|
|
||||||
|
has_one_attached_with_default(:main_image, Image::DefaultProfileUrl,
|
||||||
|
filename: "main_image_#{SecureRandom.uuid}#{Pathname.new(Image::DefaultProfileUrl).extname}")
|
||||||
|
|
||||||
|
has_one_attached_with_default(:background_image, Image::DefaultCampaignUrl,
|
||||||
|
filename: "background_image_#{SecureRandom.uuid}#{Pathname.new(Image::DefaultCampaignUrl).extname}")
|
||||||
|
|
||||||
|
|
||||||
scope :not_deleted, -> { where(deleted: [nil, false]) }
|
scope :not_deleted, -> { where(deleted: [nil, false]) }
|
||||||
|
|
|
@ -111,7 +111,17 @@ class Nonprofit < ApplicationRecord
|
||||||
has_one_attached_with_sizes(:second_image, {nonprofit_carousel: [590, 338], thumb: [188, 120], thumb_explore: [100, 100]})
|
has_one_attached_with_sizes(:second_image, {nonprofit_carousel: [590, 338], thumb: [188, 120], thumb_explore: [100, 100]})
|
||||||
has_one_attached_with_sizes(:third_image, {nonprofit_carousel: [590, 338], thumb: [188, 120], thumb_explore: [100, 100]})
|
has_one_attached_with_sizes(:third_image, {nonprofit_carousel: [590, 338], thumb: [188, 120], thumb_explore: [100, 100]})
|
||||||
|
|
||||||
|
has_one_attached_with_default(:logo, Image::DefaultProfileUrl,
|
||||||
|
filename: "logo_#{SecureRandom.uuid}#{Pathname.new(Image::DefaultProfileUrl).extname}")
|
||||||
|
has_one_attached_with_default(:background_image, Image::DefaultNonprofitUrl,
|
||||||
|
filename: "background_image_#{SecureRandom.uuid}#{Pathname.new(Image::DefaultNonprofitUrl).extname}")
|
||||||
|
has_one_attached_with_default(:main_image, Image::DefaultProfileUrl,
|
||||||
|
filename: "main_image_#{SecureRandom.uuid}#{Pathname.new(Image::DefaultProfileUrl).extname}")
|
||||||
|
has_one_attached_with_default(:second_image, Image::DefaultProfileUrl,
|
||||||
|
filename: "second_image_#{SecureRandom.uuid}#{Pathname.new(Image::DefaultProfileUrl).extname}")
|
||||||
|
has_one_attached_with_default(:third_image, Image::DefaultProfileUrl,
|
||||||
|
filename: "third_image_#{SecureRandom.uuid}#{Pathname.new(Image::DefaultProfileUrl).extname}")
|
||||||
|
|
||||||
serialize :achievements, Array
|
serialize :achievements, Array
|
||||||
serialize :categories, Array
|
serialize :categories, Array
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,8 @@ class Profile < ApplicationRecord
|
||||||
|
|
||||||
has_one_attached :picture
|
has_one_attached :picture
|
||||||
has_one_attached_with_sizes(:picture, {normal: 150, medium:100, tiny: 50})
|
has_one_attached_with_sizes(:picture, {normal: 150, medium:100, tiny: 50})
|
||||||
|
has_one_attached_with_default(:picture, Image::DefaultProfileUrl,
|
||||||
|
filename: "picture_#{SecureRandom.uuid}#{Pathname.new(Image::DefaultProfileUrl).extname}")
|
||||||
|
|
||||||
belongs_to :user
|
belongs_to :user
|
||||||
has_many :activities # Activities this profile has created
|
has_many :activities # Activities this profile has created
|
||||||
|
|
Loading…
Reference in a new issue