NoMethodError in Shelf#newbooks

Showing /app/app/views/shelf/_header.html.erb where line #21 raised:

undefined method `url' for nil:NilClass
Extracted source (around line #21):
19
20
21
22
23
24
              
<h1>
<!-- name == shelf.nil? ? '' : shelf.name %> -->
<% if shelf.url.to_s != '' %>
<%= link_to shelf.name, shelf.url %>の本棚
<% else %>
<%= shelf.name %>の本棚

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

Rails.root: /app

Application Trace | Framework Trace | Full Trace

Request

Parameters:

{"shelfname"=>"akizo_mickey"}

Response

Headers:

None