Using Rails 4.2, we are allowing users to upload images to Cloudinary only using HTTP links. Our code in our model is:
upload = Cloudinary::Uploader.upload(self.picture_link.to_s)
This works well. We don't want to allow very large uploads, and it looks like Cloudinary is automatically restricting files to 10MB or below, which is fine for us.
On our development site, when a 10MB+ upload is attempted, Rails provides a useful error message. See attached PNG.
CloudinaryException in ItemsController#update
File size too large. Got 12984953. Maximum is 10485760.
Here is our question: What is the best way to have Rails provide an error message like this on our production website? On our production website, we are not showing errors:
config.consider_all_requests_local = false
It would be a security risk to set this to true, as that would expose all of our app's errors to the world.
We need a way only return this one particular exception to the user in some way.
We've looked at this RailsCast on handling exception responses: http://railscasts.com/episodes/53-handling-exceptions-revised?autoplay=true
... But we're not sure how we would return this to the user:
CloudinaryException (File size too large. Got 12984953. Maximum is 10485760.)
Post is closed for comments.