Skip to content

Clarification on "Deleting Friends" #67

Description

@paul-howard

In the section "Hands On > Deleting Friends," the text states:

To support deletion on friends show route, we just need to add the same link with the action delete and implement the action.

In fact, the Delete link required in friends/show.hbs is not exactly the same as the previously shown link in friends/index.hbs.

Figuring out exactly why (and more importantly, how) the second link needed to be different was a nice little exercise for me, but future readers will probably appreciate a more explicit acknowledgment that the Delete link in index.hbs passes the model to the action by referencing a |friend| parameter that gets set in the #each block:

{{#each model as |friend|}}
  ...
    ...
    <td><a href="#" {{action "delete" friend}}>Delete</a></td>
  ...
{{/each}}

Whereas in show.hbs, there is no block-scope variable friend to reference, therefore:

<a href="#" {{action "delete"model}}>Delete</a>

...is required.

Since the final version of show.hbs is never shown in the text (at least not in this section), this could be a major stumbling block for less experienced readers, especially those unfamiliar with the ruby syntax on which this is based.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions