Hello, I'm writting some helper methods to write forms, so I have this working code: class TableFormBuilder < ActionView::Helpers::FormBuilder ["file_field", "password_field", "text_field"].each do |name| define_method(name) do |label, *args| @template.content_tag(:tr, @template.content_tag(:td, @template.content_tag(:label, label.to_s.humanize)) + @template.content_tag(:td, super)) end end end
From the documentation of content_tag, I see it has two styles: content_tag(tag, content) or <% content_tag(tag) do %>content<% end %>
I'd like to use the second style, but I'm not in a view, so, how do I output to the browser the same way a view does?
Or asking in another way, how do I make this work:
class TableFormBuilder < ActionView::Helpers::FormBuilder ["file_field", "password_field", "text_field"].each do |name| define_method(name) do |label, *args| @template.content_tag(:tr) do @template.content_tag(:td) do @template.content_tag(:label, label.to_s.humanize) end