8000 Support rails 6.1 · activeadmin/activeadmin@bc1e581 · GitHub
[go: up one dir, main page]

Skip to content

Commit bc1e581

Browse files
committed
Support rails 6.1
but use tag.attributes if available
1 parent 95996d4 commit bc1e581

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

lib/active_admin/views/components/active_admin_form.rb

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,23 @@ def build(form_builder, *args, &block)
132132
legend = args.shift if args.first.is_a?(::String)
133133
legend = html_options.delete(:name) if html_options.key?(:name)
134134
legend_tag = legend ? "<legend class=\"fieldset-title\">#{ERB::Util.html_escape(legend)}</legend>" : ""
135-
fieldset_attrs = tag.attributes html_options
135+
fieldset_attrs = tag_attributes html_options
136136
@opening_tag = "<fieldset #{fieldset_attrs}>#{legend_tag}<ol>"
137137
@closing_tag = "</ol></fieldset>"
138138
super(*(args << html_options), &block)
139139
end
140+
141+
private
142+
143+
def tag_attributes(html_options)
144+
if Rails::VERSION::MAJOR <= 6
145+
# Reimplement tag.attributes to backport support for Rails 6.1.
146+
# TODO: this can be removed when support for Rails 6.x is dropped
147+
tag.tag_options(html_options.to_h).to_s.strip.html_safe
148+
else
149+
tag.attributes html_options
150+
end
151+
end
140152
end
141153

142154
class SemanticActionsProxy < FormtasticProxy

0 commit comments

Comments
 (0)
0