Skip to main content
Ask A Question
Notifications
You’re not receiving notifications from this thread.
Subscribe

ActiveStorage trix image before record exist.

Rails • Asked by alogach

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. 😜


Login or Create An Account to join the conversation.

Subscribe to the newsletter

Join 31,152+ developers who get early access to new screencasts, articles, guides, updates, and more.

    By clicking this button, you agree to the GoRails Terms of Service and Privacy Policy.

    More of a social being? We're also on Twitter and YouTube.