NoMethodError in Shelf#show

Showing /app/app/views/shelf/_detaillist.html.erb where line #45 raised:

undefined method `name' for nil:NilClass
Extracted source (around line #45):
43
44
45
46
47
48
              
<td>
<% Entry.where(:book_id => book.id).each { |entry| %>
<% if entry.shelf.name !~ /_deleted/ %>
<%= link_to entry.shelf.name, :shelfname => entry.shelf.name, :action => 'edit', :isbn => book.isbn %>
<% end %>
<% } %>

Trace of template inclusion: app/views/shelf/show.html.erb

Rails.root: /app

Application Trace | Framework Trace | Full Trace

Request

Parameters:

{"list"=>"detail", "sort"=>"score", "shelfname"=>"きくりん"}

Response

Headers:

None