You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a model Image which has a role:string attribute and mounts :image_file uploader. I want to check the role attribute in my ImageFileUploader class, and produce a different set of versions depending on its value:
version :thumb do
# always produce this
process resize_to_fit: [240, 240]
end
version :normal, if: :not_banner? do
# only produce this if role != "banner"
process resize_to_fit: [1200, 1200]
end
version :banner, if: :is_banner? do
# only produce this if role == "banner"
process resize_to_fill: [1200, 600]
end
def not_banner?(image)
model.role != "banner"
end
def is_banner?(image)
model.role == "banner"
end
If I upload an image and set the role to "banner" only the :thumb gets created. For any other role the :normal version is produced and the :banner version is skipped - just as expected. Why doesn't the :is_banner? condition work here?
The text was updated successfully, but these errors were encountered:
CarrierWave processing happens on the assignment of image_file, without waiting for the assignment of role.
Please make sure that role is set to correct value, before assigning the file.
I have a model
Image
which has arole:string
attribute and mounts:image_file
uploader. I want to check therole
attribute in myImageFileUploader
class, and produce a different set of versions depending on its value:If I upload an image and set the role to "banner" only the
:thumb
gets created. For any other role the:normal
version is produced and the:banner
version is skipped - just as expected. Why doesn't the:is_banner?
condition work here?The text was updated successfully, but these errors were encountered: