Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After uploading File in ActionText (Trix) it can not be found when rendering (missing attachable) #2538

Closed
4 of 11 tasks
tamaloa opened this issue Feb 29, 2024 · 9 comments · Fixed by #2639
Closed
4 of 11 tasks
Assignees
Labels
Bug Something isn't working

Comments

@tamaloa
Copy link

tamaloa commented Feb 29, 2024

Describe the bug

Steps to Reproduce

Steps to reproduce the behavior:

  1. Go to https://main.avodemo.com/avo/resources/posts/new
  2. Insert Title and save
  3. Edit Post
  4. In BODY field attach non image File (for example README.md)
  5. Save and "show content"
  6. No uploaded file is shown

Expected behavior & Actual behavior

Expected behaviour would be to show the uploaded file, actual behaviour is showing nothing.

I replicated the problem on a fresh minimal setup (https://github.com/tamaloa/AvoActionTextAttachmentTest ).
If using the rails built in create action (and trix editor) a upload is rendered in rails view as expected (via _blob.html.erb partial).
If adding a file to a actiontext via AVO gem the attachment does not seem to be found.

Stacktrace from showing a resource created with avo (with file upload)

Processing by NotesController#show as HTML
  Parameters: {"id"=>"2"}
  Note Load (0.1ms)  SELECT "notes".* FROM "notes" WHERE "notes"."id" = ? LIMIT ?  [["id", 2], ["LIMIT", 1]]
  ↳ app/controllers/notes_controller.rb:63:in `set_note'
  Rendering layout layouts/application.html.erb
  Rendering notes/show.html.erb within layouts/application
  ActionText::RichText Load (0.1ms)  SELECT "action_text_rich_texts".* FROM "action_text_rich_texts" WHERE "action_text_rich_texts"."record_id" = ? AND "action_text_rich_texts"."record_type" = ? AND "action_text_rich_texts"."name" = ? LIMIT ?  [["record_id", 2], ["record_type", "Note"], ["name", "content"], ["LIMIT", 1]]
  ↳ app/views/notes/_note.html.erb:4
  Rendered .rvm/gems/ruby-3.2.2/gems/actiontext-7.1.3.2/app/views/action_text/attachables/_missing_attachable.html.erb (Duration: 0.2ms | Allocations: 116)
  Rendered .rvm/gems/ruby-3.2.2/gems/actiontext-7.1.3.2/app/views/action_text/contents/_content.html.erb within layouts/action_text/contents/_content (Duration: 5.9ms | Allocations: 10446)
  Rendered notes/_note.html.erb (Duration: 29.8ms | Allocations: 30333)
  Rendered notes/show.html.erb within layouts/application (Duration: 34.2ms | Allocations: 33322)
  Rendered layout layouts/application.html.erb (Duration: 75.0ms | Allocations: 83570)
Completed 200 OK in 116ms (Views: 77.1ms | ActiveRecord: 1.7ms | Allocations: 106168)

Models and resource files

https://github.com/tamaloa/AvoActionTextAttachmentTest

System configuration

ruby 3.2.2, rails 7.1.3.2, avo (3.4.2)

License type:

  • Community
  • Pro
  • Advanced

Are you using Avo monkey patches, overriding views or view components?

  • Yes. If so, please post code samples.
  • No

Screenshots or screen recordings

Peek.2024-02-29.11-38.mp4

Impact

  • High impact (It makes my app un-usable.)
  • Medium impact (I'm annoyed, but I'll live.)
  • Low impact (It's really a tiny thing that I could live with.)

Urgency

  • High urgency (I can't continue development without it.)
  • Medium urgency (I found a workaround, but I'd love to have it fixed.)
  • Low urgency (It can wait. I just wanted you to know about it.)

Workaround is to let users upload Files via a standard rails edit view which is far from ideal :(

@Paul-Bob Paul-Bob moved this to Next up in Issues Mar 4, 2024
@Paul-Bob Paul-Bob moved this from Next up to In Progress in Issues Mar 4, 2024
@Paul-Bob Paul-Bob moved this from In Progress to Next up in Issues Mar 5, 2024
Copy link
Contributor

This issue has been marked as stale because there was no activity for the past 15 days.

@github-actions github-actions bot added the Stale label Mar 18, 2024
@Paul-Bob Paul-Bob added Bug Something isn't working and removed Stale labels Mar 18, 2024
@adrianthedev
Copy link
Collaborator

@tamaloa can you please try it on https://www.avodemo.com/avo/resources/posts/49 and let us know if you get the same "broken" results?

If this works on avodemo, the next step would be to try and reproduce it in a simple repo so we can troubleshoot it ourselves.

There could be the case that it's something local.

Thank you!

@adrianthedev
Copy link
Collaborator

@tamaloa sorry about that. I now read the whole message and saw the reproduction repo.
We'll have a look!

@tamaloa
Copy link
Author

tamaloa commented Mar 19, 2024

Cool - it's also still reproducable on avodemo.com (just tried).

@Paul-Bob
Copy link
Contributor

Hello, I reproduced it and in avodemo the scenario is different. In avodemo we have this options:

      hide_attachment_url: true,
      hide_attachment_filename: true,
      hide_attachment_filesize: true

That cause files without preview to be hidden.

I was able to reproduce the issue reported only when using has_rich_text.

@tamaloa
Copy link
Author

tamaloa commented Apr 17, 2024

Thanks for looking into this.

I tried to verify the fix by using avo from current main branch (rev df2262c) in my reproduction repository: https://github.com/tamaloa/AvoActionTextAttachmentTest (Note: necessary to run rake avo:build-assets when pulling gem directly from github).

Unfortunately, for me, the bug has not been fixed. As can be seen in below screenrecording (using the reproduction repository above) a uploaded file still is neither shown/downloadable in avo itself nor in a standard rails view.

avo-trix-fileupload.mp4

Furthermore a file which was attached via the default rails actiontext editor now results in an exception in avo if one wants to show/edit this field (see end of screenrecording). This renders our current workaround (using a seperate editor only for adding files) less useful as we would have to exclude editing the whole field from avo.

@Paul-Bob
Copy link
Contributor

@tamaloa try it after removing the attachment_key, when using rich text the attachment_key is not needed, that was the idea of the fix PR

@tamaloa
Copy link
Author

tamaloa commented Apr 18, 2024

I actually already had tried it without the key and now double checked it (tamaloa/AvoActionTextAttachmentTest@4408303). Unfortunately it still does not work for me I get the behaviour as shown in above video.

@Paul-Bob Paul-Bob reopened this Apr 18, 2024
@Paul-Bob Paul-Bob moved this from Done to In Progress in Issues Apr 18, 2024
@Paul-Bob Paul-Bob moved this from In Progress to In Review in Issues Apr 19, 2024
@Paul-Bob Paul-Bob moved this from In Review to In Progress in Issues Apr 19, 2024
@Paul-Bob
Copy link
Contributor

Can confirm that the issue persist, I included it on this issue list #2715 lets keep the conversation there since there were already many trix related open issues

@github-project-automation github-project-automation bot moved this from In Progress to Done in Issues Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants