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

Author index page should have a link to delete an author #11

Open
swt2public opened this issue Oct 27, 2022 · 1 comment
Open

Author index page should have a link to delete an author #11

swt2public opened this issue Oct 27, 2022 · 1 comment

Comments

@swt2public
Copy link

Scenario

Given an author named 'Alan Turing'
When users visit the authors index page
Then it should have link to delete an author

Hints

To delete a record following the REST paradigm, a DELETE request needs to be made.
As not many browsers support this directly, the DELETE call is made using JavaScript.
Newer versions of Rails support this using the turbo dependency.
Install it using rails importmap:install turbo:install stimulus:install (answer 'y' to overwrite existing files).

The following data attributes (read by JS) turn the usual GET request of a link into a DELETE (with confirmation messge):
<%= link_to 'Delete', author_path(author), data: {turbo_method: :delete, turbo_confirm: "Are you sure?"} %>

After an author is deleted Author.count should have decreased.

A destroy controller action is needed.
Here is the relevant section (5.13) of the Rails Guide. (Please be aware that the link_to syntax of the guide is outdated, see code above.)

Error

Expected to find css "a[data-turbo-method='delete'][href='/authors/1']" but there were no matches

18 exercise tests have passed. There are 44 in total. You will solve multiple at once towards the end.

chrisma added a commit that referenced this issue Oct 28, 2022
chrisma added a commit that referenced this issue Oct 28, 2022
chrisma added a commit that referenced this issue Oct 28, 2022
@swt2public
Copy link
Author

Sorry, it's not working for me yet:

Scenario

Given an author named 'Alan Turing'
When users visit the authors index page
And a user clicks the delete link
Then no error should occour

Error

Got AbstractController::ActionNotFound: The action 'destroy' could not be found for AuthorsController

If you have problems solving this task, please don't hesitate to contact the teaching team!

chrisma added a commit that referenced this issue Oct 28, 2022
chrisma added a commit that referenced this issue Oct 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant