Bug #5609
closedundefined method `id' for nil:NilClass on host form when location not visible
Description
When a location isn't visible to a user, the host edit form can throw the following backtrace:
NoMethodError
undefined method `id' for nil:NilClass
app/views/hosts/_form.html.erb:42:in `block (2 levels) in app_views_hosts_form_html_erb___4293687029106106936_69881101386960'
app/helpers/layout_helper.rb:218:in `form_for'
app/views/hosts/_form.html.erb:7:in `block in app_views_hosts_form_html_erb___4293687029106106936_69881101386960'
app/models/taxonomy.rb:56:in `block (2 levels) in as_taxonomy'
app/models/concerns/foreman/thread_session.rb:143:in `as_location'
app/models/taxonomy.rb:55:in `block in as_taxonomy'
app/models/concerns/foreman/thread_session.rb:108:in `as_org'
app/models/taxonomy.rb:54:in `as_taxonomy'
app/views/hosts/_form.html.erb:5:in `_app_views_hosts__form_html_erb___4293687029106106936_69881101386960'
app/views/hosts/new.html.erb:7:in `_app_views_hosts_new_html_erb__692129816314295724_69881101356420'
app/models/concerns/foreman/thread_session.rb:33:in `clear_thread'
lib/middleware/catch_json_parse_errors.rb:9:in `call'