Reputation: 697
I have one form_for for saving NewsItems (something like posts). Each news item should have one cover image, title, short text... The image should appear as a preview before the form is filled and there should be some loader that shows the progress of the image being uploaded. For the preview and the progress bar I use Jquery file uploader.
I tryed to use nested forms but jquery file uploader submits the whole form when the image is loaded and the text fields are stil empty. When I press submit it will submit the form but this time without the image.
I added an extra column in news item table with the name image. Also added hidden filed :image and validation that it must be present. Now when the jquery file upload is done it add's the image in the image tag and it add the base64 code of the image in the hidden field with name :image.
The problem looks like it's solved but in the terminal I see a big base64 code and it's looks like there is a better way to do it.
Please, do you know how to disable the automatic submiting with jquery file upload or how to have the upload progress and the preview image without the base64 code in the params?
Thank you in advance!
Upvotes: 3
Views: 431
Reputation: 15515
To prevent the base64 string filling up you logs, use the filter_parameters
setting in your config/application.rb
, ie:
# Configure sensitive parameters which will be filtered from the log file.
config.filter_parameters += [:password, :token, :encoded_image]
Upvotes: 0