From 0c6b4955601c15d3df0034474c24114ecc7e6588 Mon Sep 17 00:00:00 2001 From: Earlopain <14981592+Earlopain@users.noreply.github.com> Date: Wed, 9 Oct 2024 16:20:26 +0200 Subject: [PATCH] Handle both rails 7.2 and rails 8.0 field types They got renamed in: * https://github.com/rails/rails/pull/52432 * https://github.com/rails/rails/pull/52467 This ensures the correct classes are generated for both old and new versions (cherry picked from commit 68d819afc165f3b74226130cabec334a8ce8b9d3) --- .../tailwindcss/scaffold/templates/_form.html.erb.tt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/generators/tailwindcss/scaffold/templates/_form.html.erb.tt b/lib/generators/tailwindcss/scaffold/templates/_form.html.erb.tt index 4ce66d6..487f2f5 100644 --- a/lib/generators/tailwindcss/scaffold/templates/_form.html.erb.tt +++ b/lib/generators/tailwindcss/scaffold/templates/_form.html.erb.tt @@ -26,9 +26,9 @@ <%%= form.<%= attribute.field_type %> :<%= attribute.column_name %>, multiple: true, class: "block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full" %> <% else -%> <%%= form.label :<%= attribute.column_name %> %> -<% if attribute.field_type == :text_area -%> +<% if attribute.field_type == :textarea || attribute.field_type == :text_area -%> <%%= form.<%= attribute.field_type %> :<%= attribute.column_name %>, rows: 4, class: "block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full" %> -<% elsif attribute.field_type == :checkbox -%> +<% elsif attribute.field_type == :checkbox || attribute.field_type == :check_box -%> <%%= form.<%= attribute.field_type %> :<%= attribute.column_name %>, class: "block mt-2 h-5 w-5" %> <% else -%> <%%= form.<%= attribute.field_type %> :<%= attribute.column_name %>, class: "block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full" %>