boilerman icon indicating copy to clipboard operation
boilerman copied to clipboard

NoMethodError - undefined method `empty?' for nil:NilClass:

Open dankohn opened this issue 9 years ago • 0 comments

I'm trying to run boilerman on a complex application that uses papertrail, activeadmin, and a bunch of other gems.

http://localhost:3000/boilermanis failing to render the with the error:

NoMethodError - undefined method `empty?' for nil:NilClass:

The issue is with line 29 of https://github.com/tomekr/boilerman/blob/master/app/views/boilerman/actions/index.html.erb#L29 :

<% filter_count = actions.map{|_, filters| filters.empty? ? 1 : filters}.flatten.count %>

Specifically, these are the values of the Local Variables in the loop:

_                   :_non_existant_route
filters             nil
controller          :_weird_controller
actions             [:_non_existant_route]
filter_count        nil
local_assigns       {}
output_buffer       nil
_old_virtual_path   nil
_old_output_buffer  nil

The .empty? in the ERB could be .blank?, but the page then fails when it reaches filters.count at https://github.com/tomekr/boilerman/blob/master/app/views/boilerman/actions/index.html.erb#L35

I haven't reviewed your code closely enough, but it looks like this filter could be ignored here: https://github.com/tomekr/boilerman/blob/master/app/controllers/boilerman/actions_controller.rb#L11

Or, we could explicitly add a next if filters.nil? to one of the loops. Could you please suggest a fix?

dankohn avatar Feb 08 '16 22:02 dankohn