abuiles / ember-101

https://leanpub.com/ember-cli-101
95 stars 23 forks source link

Clarification on "Deleting Friends" #67

Open paul-howard opened 8 years ago

paul-howard commented 8 years ago

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.