# Outputing to the browser, how?

**URL:** <https://www.ruby-forum.com/t/outputing-to-the-browser-how/115943>\
**Category:** Rails\
**Created:** [September 30, 2007, 7:21pm UTC](https://www.ruby-forum.com/t/outputing-to-the-browser-how/115943 "2007-09-30T19:21:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![JSPablo\_FernSSSSnd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e9bcb4/32.png) [@JSPablo\_FernSSSSnd](https://www.ruby-forum.com/u/JSPablo_FernSSSSnd)\
**Post date:** [September 30, 2007, 7:21pm UTC](https://www.ruby-forum.com/t/outputing-to-the-browser-how/115943/1 "2007-09-30T19:21:12Z")

</div>

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 %\>

> **[ActionView::Helpers::TagHelper](https://api.rubyonrails.org/classes/ActionView/Helpers/TagHelper.html#M000598)**
>
> Provides methods to generate HTML tags programmatically both as a modern HTML5 compliant builder style and legacy XHTML compliant tags.

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  
+  
@template.content\_tag(:td, super)  
end  
end  
end  
end

## Thank you.

J. Pablo Fernández [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) ([http://pupeno.com](http://pupeno.com))

---

<div class="post-metadata">

**Author:** ![JSPablo\_FernSSSSnd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e9bcb4/32.png) [@JSPablo\_FernSSSSnd](https://www.ruby-forum.com/u/JSPablo_FernSSSSnd)\
**Post date:** [October 1, 2007, 8:48am UTC](https://www.ruby-forum.com/t/outputing-to-the-browser-how/115943/2 "2007-10-01T08:48:54Z")

</div>

this is a known bug/inconsistency. see here: \<http://  
[dev.rubyonrails.org/ticket/7857](http://dev.rubyonrails.org/ticket/7857)\>

wait for rails 1.2.4 to make it more sensible or patch it yourself.

greetings,  
Phil

---

<div class="post-metadata">

**Author:** ![JSPablo\_FernSSSSnd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e9bcb4/32.png) [@JSPablo\_FernSSSSnd](https://www.ruby-forum.com/u/JSPablo_FernSSSSnd)\
**Post date:** [October 1, 2007, 9:23am UTC](https://www.ruby-forum.com/t/outputing-to-the-browser-how/115943/3 "2007-10-01T09:23:58Z")

</div>

Hi Pablo

If your apps is databse intensive,you owe toy ourself to take a look  
at activescaffold 🙂
