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 %> http://api.rubyonrails.org/classes/ActionView/Helpers/TagHelper.html#M000598 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 <pupeno-GAtDADarczzQT0dZR+AlfA@public.gmane.org> (http://pupeno.com) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
atpunkt-TM7Dk29TcfyELgA04lAiVw@public.gmane.org
2007-Oct-01 06:48 UTC
Re: Outputing to the browser, how?
this is a known bug/inconsistency. see here: <http:// dev.rubyonrails.org/ticket/7857> wait for rails 1.2.4 to make it more sensible or patch it yourself. greetings, Phil On 30 Sep., 19:20, "J. Pablo Fernández" <pup...-GAtDADarczzQT0dZR+AlfA@public.gmane.org> wrote:> 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 %> > > http://api.rubyonrails.org/classes/ActionView/Helpers/TagHelper.html#... > > 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 <pup...-GAtDADarczzQT0dZR+AlfA@public.gmane.org> (http://pupeno.com)--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi Pablo If your apps is databse intensive,you owe toy ourself to take a look at activescaffold :-) On Oct 1, 1:20 am, "J. Pablo Fernández" <pup...-GAtDADarczzQT0dZR+AlfA@public.gmane.org> wrote:> 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 %> > > http://api.rubyonrails.org/classes/ActionView/Helpers/TagHelper.html#... > > 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 <pup...-GAtDADarczzQT0dZR+AlfA@public.gmane.org> (http://pupeno.com)--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---