Hi all,
I cannot figure out how to correctly use the with_output_buffer helper
method (located in ActionView::Helpers::CaptureHelper) inside a custom
FormBuilder.
Below follows a simplified example.
I'm trying to achieve the following behavior in an ERB as suggested in
the form_for helper docs in the Rails source:
==========
<%= form_for @object, :builder => MyFormBuilder do |my_form| %>
<%= my_form.my_dummy_div_wrapper do %>
<%= ... %>
<%= end %>
<% end %>
==========
Here's the helper:
==========
module MyHelper
class MyFormBuilder < ActionView::Helpers::FormBuilder
def my_dummy_div_wrapper(&block)
output = "<div>".html_safe
# here I should use with_output_buffer to correctly get the
block's output
output.safe_concat(with_output_buffer &block)
output.safe_concat "</div>"
output
end
end
end
==========
Inside the MyFormBuilder methods, there's no with_output_buffer method
defined so I cannot use it (and a bunch of other Rails helpers; cannot
render a partial, etc..).
I already spent two days studying the Rails source, tried lots of
things, no luck so far.
I don't think what I'm trying to accomplish is wrong: I'm not calling
view helper methods from models etc.
Any help a life saver!
Thank you,
Martin
--
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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.