Tom PRO
Joined 7/7/2021
Tom PRO said over 3 years ago on Building a Questionnaire :
Hi,

Having an annoying issue on this one - it looks like adding multiple answers to a question when creating a new questionnaire causes only the last answer to be accepted (only shows one in the dev log in the request too),  but it works fine when editing an existing questionnaire. It looks like 'Add answer' is creating multiple of the same block of HTML when creating a new questionnaire, i.e. 

var content = this.templateTarget.innerHTML.replace(/TEMPLATE_RECORD/g, new Date().getTime())

in nested_form_controller.js appears not to be working correctly (I think) - even when directly copy/pasting from the code blocks above, but only for new questionnaires. Any ideas?

Tom PRO said almost 3 years ago on Cropping Active Storage Uploads :
  Not sure if this is something you can deal with here (or perhaps an update episode for Rails 7), but this appears to be quite broken with Rails 7.0.1 - perhaps there are intervening changes with active storage?

Specifically, choosing an image from the file field, leads to a 500 with the log showing 'ActiveStorage::InvalidDirectUploadTokenError (ActiveStorage::InvalidDirectUploadTokenError):'
with the console showing:
TypeError: undefined is not an object (evaluating 'blob.signed_id')

(note that using the built-in 'direct_upload: true' on a file field does correctly work and upload, but of course, that doesn't produce nice cropping :)

Tom PRO said almost 3 years ago on Cropping Active Storage Uploads :
More information, for those reading above - 7.0.1 issues appear to be related to:

https://github.com/rails/rails/issues/43971
and
https://github.com/rails/rails/pull/44287/files

It looks like the change that breaks this episode's code (requiring that you specify

constructor(file, checksum, url, directUploadToken, attachmentName)
instead of
constructor(file, checksum, url)

has been reverted, and may make it to a future release, before being redesigned - this episode's code works again on rails main branch, for instance.



Tom PRO said almost 3 years ago on Cropping Active Storage Uploads :
  This doesn't appear to work for editing existing images (you have to reupload a new one, even when in edit view) - is there a quick way to make that work?