All threads / ActiveStorage trix image before record exist.

Ask A Question

Notifications

You’re not receiving notifications from this thread.

ActiveStorage trix image before record exist.

alogach asked in Rails

Hi,

I have a Concept model with description string field.
Concept has_many_attached :images, I use them to store images that I dragged into trix wysiwyg.
Everything works great if Concept already exist and I edit it.
My goal is to give user option to upload images right on creation step.

I have in mind some options:

  • store images in other temporary record, and rewrite after save ( the worst one);
  • pre save record in background while user fill ing form (should delete it if he cancel action, ghost records possible);
  • do not allow editing description on creation step (easiest option, but does not meet expectation).

Will appreciate any ideas.
Thx.

I would probably recommend the middle option. One improvement you can make on that rather than deleting if the user cancels is to just have an idea of a "draft" record.

This would be a record you're editing but haven't fully published yet. It would only be visible to you and that way your images are attached to this record and you can safely delete them.

That helps in a lot of ways and also makes it so the user doesn't lose any progress as well which can be nice.

Thank you Chris!
Definitely draft is a great option.

Forgot to mention, this is what Basecamp does when you create like a new Message. Same concept as writing a draft email in GMail too.

Adding this to my list for a screencast. 😜

Join the discussion

Want to stay up-to-date with Ruby on Rails?

Join 35,095+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    logo Created with Sketch.

    Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

    © 2020 GoRails, LLC. All rights reserved.