Simplify object and association checks

* check for <object> instead of <object>.nil?
* check for <association>_id? instead of <association>.nil? (avoids
  record loading)
This commit is contained in:
2025-01-16 20:42:18 +01:00
parent c908063212
commit 7962cdf169
13 changed files with 24 additions and 26 deletions

View File

@@ -8,11 +8,11 @@
<%= turbo_stream.append :unit_form do %>
<%- tabular_form_with model: @unit, html: {id: ids[:form_tag]} do |form| %>
<%= form.hidden_field :base_id unless @unit.base.nil? %>
<%= form.hidden_field :base_id if @unit.base_id? %>
<% end %>
<% end %>
<% if @unit.base %>
<% if @unit.base_id? %>
<%= turbo_stream.remove ids[:row] %>
<%= turbo_stream.after @unit.base, partial: 'form', locals: ids %>
<% else %>