Terrastories / terrastories

Terrastories is a geostorytelling application for mapping, managing and sharing place-based stories.
https://terrastories.app
MIT License
319 stars 157 forks source link

[Rails][Bug] Remove video attachment from Story view in Administrate is not working #705

Closed rudokemper closed 2 years ago

rudokemper commented 2 years ago

Describe the bug Currently, it seems like an error is being thrown when trying to remove media attachment from the Story edit view in Administrate. The expected behavior is that clicking the "Remove" button should remove the media attachment, but instead we are taken to a Rails error page.

To Reproduce Steps to reproduce the behavior:

  1. Add a video to a story, and save the story
  2. Edit the story
  3. Click the "remove" link below the media attachment
  4. See error

Expected behavior A clear and concise description of what you expected to happen.

Screenshots image Attachment remove error

andersan commented 2 years ago

Hey, is this issue still relevant, and is it a good one to start with?

Are there more high-priority issues on this project that need to be addressed and which are a similar level of complexity?

rudokemper commented 2 years ago

Hi @andersan, yes this issue is super relevant still, and I imagine it's a good one to become acquainted with the Rails and media storage side of things. Any help would be highly appreciated! I can assign you if you're interested in taking a look.

I can answer the other question a bit later on in the week.

andersan commented 2 years ago

@rudokemper just got the app set up locally and added a story, speaker and place to see how it all works.

Is this the same error you're seeing? I haven't worked with Rails in a while but can dig into it if it's the same one.

Screenshot from 2022-03-02 06-49-37

Screenshot from 2022-03-02 06-54-03

rudokemper commented 2 years ago

Interestingly no, when removing Media we are seeing this view:

image

Is that the same pathway that you took? Add Media, and then try to remove?

andersan commented 2 years ago

Maybe it is a configuration issue with the way the app is set up on my local environment. I'm running ubuntu 20.04, a fresh install of docker, and using Chrome to test.

Steps I took to get there:

  1. Add media
  2. Save the story
  3. Verify that the story has the media added looking at the map
  4. Edit the story
  5. Try to remove the media

In the terminal running the local server/docker, this is the output when this error happens:

Started DELETE "/admin/stories" for 172.18.0.1 at 2022-03-02 14:42:02 +0000
Cannot render console from 172.18.0.1! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255

ActionController::RoutingError - uninitialized constant StoriesController:

Started POST "/__better_errors/71f105941e69c37a/variables" for 172.18.0.1 at 2022-03-02 14:42:02 +0000
Cannot render console from 172.18.0.1! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255
Since there is no EDITOR or BETTER_ERRORS_EDITOR environment variable, using Textmate by default.

After making some changes to the rails/config/environments/development.rb file as suggested here, the error message is slightly different ("Cannot render console" messages shown above no longer appear):

Started DELETE "/admin/stories?attachment_id=3&record_id=6" for 172.18.0.1 at 2022-03-02 15:05:14 +0000

ActionController::RoutingError - uninitialized constant StoriesController:
Started POST "/__better_errors/5001f7e0e0a43da5/variables" for 172.18.0.1 at 2022-03-02 15:05:14 +0000
Since there is no EDITOR or BETTER_ERRORS_EDITOR environment variable, using Textmate by default.

Screenshot from 2022-03-02 10-09-41

Note that after making those changes to the development.rb file, I can create, update and delete a story without any issue.

rudokemper commented 2 years ago

Nice! This change permits you to remove a media attachment from a story as well? If so, please do feel free to submit a PR and we can test it out!

andersan commented 2 years ago

The above issue was just a local config issue. My IP wasn't recognized - I'll commit that change in case it helps future developers.

I added a new stories controller outside the Admin context via "rails g controller stories". In the master branch, the Stories controller only exists in the admin folder. Adding that controller changes the error message to the following:

The action 'delete' could not be found for StoriesController

Adding "delete" to the admin stories controller might fix the issue, but I'm not sure. I'm a rails novice (work a lot more with JS/node.js) so am learning as I make these changes.

andersan commented 2 years ago

Think the issue was:

  1. the route was pointing at "stories" instead of "admin/stories". the route for deleting "places" seems like it might have the same issue
  2. there was no logic in the admin stories controller to remove the attachment

This should be fixed. Removing images/attachments and deleting stories both seem to work with these changes. I wa sn't sure if the change would result in story deletion being broken.

PR here: https://github.com/Terrastories/terrastories/pull/713