ruby-on-railsformbuildercontent-for

content_for Inside Formbuilder


I've got a formbuilder field specifically for doing DateTime using jQuery. What I'd like to do is have the helper able to push content out to my < head > through content_for. Any ideas?

Thanks, Stefan


Solution

  • You can call any helper method on the @template instance variable. It holds the current template context.

    class MyBuilder < ActionView::Helpers::FormBuilder
    
      def this_method_appends_content_for(content)
        @template.content_for(:head, content)
      end
    
    end