I'm deploying a fairly simple Rails 6.1 app to Heroku. I'm hitting this error on a deploy to Heroku but not locally. I've looked through all the previous posts related to this error, none are actually empty?, they usually are properties on objects that aren't in the database. I can't figure this one out. The error I'm receiving is not related to a database call. My home controller makes no calls to the database, the index page is simple and the error message I'm receiving has to do with path calls built into Rails:
ActionView::Template::Error (undefined method 'empty?' for nil:NilClass):
14: <!-- Inner -->
15: <ul class="sidenav-inner py-1">
16: <li class="sidenav-divider mt-0"></li>
17: <li class="sidenav-item<%= current_page?(root_path) ? ' active' : '' %>">
18: <%= link_to root_path, class: "sidenav-link" do %>
19: <i class="sidenav-icon fad fa-home"></i><div>Home</div>
20: <% end %>`
app/views/layouts/partials/_layout-sidenav.html.erb:17
app/views/layouts/main/layout-without-navbar.html.erb:9
app/views/layouts/main/layout-without-navbar.html.erb:1
My controller:
class HomeController < ApplicationController
def index
@title = 'Home'
end
end
My index page:
<h4 class="font-weight-bold py-3 mb-4">Home</h4>
<p>
This page is an example of basic layout.
</p>
<p>
<button class="btn btn-primary btn-lg">Button</button>
</p>
- I've removed the line the error is on (17) and the same error gets thrown on the next line (18) calling root_path.
- I've verified that my database migrations have run on Heroku.
- I've seeded the Heroku database with sample data for all classes from seeds.rb. I normally wouldn't do this but I wanted to troubleshoot to see if there was an query returning nil somewhere.
I understand what the nil:NilClass error is, I'm attempting to call empty? on a class that's nil. For one, when I do a search through my code there are 0 results for empty? so it must be called in an underlying somewhere. Also, there are no database calls here, and why would a path be nil? I'm starting to feel like this is a red herring error. I am using Devise so I'm curious if it's somehow related to that and I haven't configured something correctly.
Any ideas anyone can give I'd appreciate.
/gems/actionpack-6.1.0/lib/action_dispatch/routing/route_set.rb:784:in 'optimize_routes_generation?'default_url_options.empty?- azatelli