vendredi 8 mai 2015

Best way to deal with an error caused by a method returning no values?

The following code is implemented to read in values and fill in a table with the appropriate values, however when one of the methods doesn't return anything it produces an error and crashes the page.

<tr class="event-row" >
  <td><%= event.description %></td>
  <td><%= event.contact.name %></td>
  <td><%= event.start.strftime('%H:%M') %></td>
  <td><%= event.end.strftime('%H:%M') %></td>
  <td><%= link_to "edit", edit_event_path(event) %></td>
  <td><%= link_to "delete", event, method: :delete, data: {confirm: "Are       you sure?"} %>
  <td><%= link_to "show", event_path(event) %></td>
</tr>

How can you check to see if the methods are returning no values?

Aucun commentaire:

Enregistrer un commentaire