Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6383745
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:41:18+00:00 2026-05-25T02:41:18+00:00

This is similiar to Trying to extend ActionView::Helpers::FormBuilder but I don’t want to use

  • 0

This is similiar to Trying to extend ActionView::Helpers::FormBuilder but I don’t want to use :builder => MyThing.

I want to extend form builder to add custom methods. This is the current situation:

module ActsAsTreeHelpers
  def acts_as_tree_block(method, &block)
    yield if block_given?
  end

end


ActionView::Helpers::FormBuilder.send :include, ::ActsAsTreeHelpers

Console:

ruby-1.9.2-p180 :004 > ActionView::Helpers::FormBuilder.included_modules
=> [ActsAsTreeHelpers, ...]

But the following gives me: undefined method acts_as_tree_block for #<ActionView::Helpers::FormBuilder:0xae114dc>

<%= form_for thing do |form| %>
  <%= form.acts_as_tree_block :parent_id, {"test"} %>
<% end %>

What am I missing here?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T02:41:19+00:00Added an answer on May 25, 2026 at 2:41 am

    I also had the same problem.
    I tried to add a new file named form_builder.rb in folder config/initializers of my project and it works well now.

    Below are some contents of my solution.
    base_helper.rb

    def field_container(model, method, options = {}, &block)
      css_classes = options[:class].to_a
      if error_message_on(model, method).present?
        css_classes << 'withError'
      end
      content_tag('p', capture(&block), :class => css_classes.join(' '), :id => "#{model}_#{method}_field")
    end
    

    form_builder.rb

    class ActionView::Helpers::FormBuilder
      def field_container(method, options = {}, &block)
        @template.field_container(@object_name,method,options,&block)
      end
    
      def error_message_on(method, options = {})
        @template.error_message_on(@object_name, method, objectify_options(options))
      end
    end
    ActionView::Base.field_error_proc = Proc.new{ |html_tag, instance| "<span class=\"field_with_errors\">#{html_tag}</span>".html_safe }
    

    _form.html.erb

    <%= f.field_container :name do %>
      <%= f.label :name, t("name") %> <span class="required">*</span><br />
      <%= f.text_field :name %>
      <%= f.error_message_on :name %>
    <% end %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is what I'm trying to do something similar to the following request, but
This is somewhat similiar to this : pthread function from a class But the
Okay, this might be confusing. What I'm trying to do is use an enumerator
I'm trying to do something like this, but Java won't let me. I suspect
I am trying to do something similar to this but in Android. In Android
I'm getting this JS error while trying to use Ember routing: Uncaught TypeError: Object
I'm trying to create a layout similar to this: alt text http://img20.imageshack.us/img20/3533/stackn.png Here's the
I'm trying to write something similar to this (sorry if the sample is not
I am trying to do something very similar to this c# docs example :
I'm trying to build a view that operators something similar to this: The user

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.