Skip to content

Adding the delete action to the building a web app guide#349

Open
carolyncole wants to merge 3 commits intohanami:mainfrom
carolyncole:add-delete
Open

Adding the delete action to the building a web app guide#349
carolyncole wants to merge 3 commits intohanami:mainfrom
carolyncole:add-delete

Conversation

@carolyncole
Copy link
Contributor

@carolyncole carolyncole commented Mar 3, 2026

This is a follow on to #347

Copy link
Contributor

@katafrakt katafrakt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, nice work! I left few comments about the content.

Copy link
Member

@timriley timriley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great, thank you @carolyncole! I've just left a couple of extra suggestions in addition to @katafrakt's. Once these are sorted, this will be good to merge :)

Thank you again! ❤️

def handle(request, response)
result = book_repo.delete(request.params[:id])

response.flash[:notice] = if !result.nil?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regarding the logic in this action, I think we can just assume that all deletes will be successful. This means we can do away with the result conditional, and just jump straight to setting response.flash[:notice] = "Book deleted" straight away.

This would also remove the issue @katafrakt raised regarding the flash.now in the "else" side of the conditional.


To delete a book we will only need one action, destroy.

First, let's update our routes. We could add `:delete` to our only list, but we can just remove the only list as we will have implemented all actions a resource provides ([:index, :show, :new, :create, :edit, :update, :delete]).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
First, let's update our routes. We could add `:delete` to our only list, but we can just remove the only list as we will have implemented all actions a resource provides ([:index, :show, :new, :create, :edit, :update, :delete]).
First, let's update our routes. We could add `:delete` to our `only:` list, but we can just remove the this as we will have implemented all actions a resource provides ([:index, :show, :new, :create, :edit, :update, :delete]).

A couple of tweaks to make the sentence a bit easier to read: distinguish "only" as a code argument for formatting it as so, and then referring to it as "this list" in the second half of the sentence. Just doing this because "only" is a common word in ordinary sentence construction.

carolyncole and others added 2 commits March 16, 2026 08:17
Co-authored-by: Paweł Świątkowski <katafrakt@users.noreply.github.com>
@carolyncole
Copy link
Contributor Author

@timriley @katafrakt Thanks for the feedback. I have updated the docs.

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

Successfully merging this pull request may close these issues.

3 participants