I have an Image uploading application running on carrierwave which restrict user from uploading image only of desired extensions \'jpg,jpeg,png\' I have put in place the v
If someone ends up here in 2016+ and wonders why correct answers found on this page or anywhere else in the web do not work, it could be because of this. At least it was in my case:
Rename
extension_white_list
~>extension_whitelist
Easy thing to miss when just copying solutions.
https://github.com/carrierwaveuploader/carrierwave/commit/06003a5044190f93d07d958b6ca9fd6f6f8fbdb2
Add this to your .yml
translation file:
en:
errors:
messages:
extension_white_list_error: "You are not allowed to upload %{extension} files, allowed types: %{allowed_types}"
content_type_whitelist_error: "You are not allowed to upload %{content_type} files, allowed types: %{allowed_types}"
Source:
https://github.com/jnicklas/carrierwave/blob/master/lib/carrierwave/locale/en.yml
for some reason my ActiveModel did not include the validation module from carrierwave upon calling mount_uploader
. I had to do include CarrierWave::Validations::ActiveModel
in my model to get the integrity validator.
Actually it is:
en:
errors:
messages:
extension_white_list_error: "You are not allowed to upload %{extension} files, allowed types: %{allowed_types}"
Source:
https://github.com/jnicklas/carrierwave/blob/master/lib/carrierwave/locale/en.yml