activefx / attribute_fu

rails multi-model forms made easy!
http://jamesgolick.com/attribute_fu
MIT License
3 stars 0 forks source link

undefined method 'h' error at add_associated_link #1

Open tobynet opened 14 years ago

tobynet commented 14 years ago

Hi, I try to use it with jQuery. But a following error are occured.

undefined method `h' for # < ActionView::Helpers::FormBuilder:0xb6eb4ff4 >
vendor/plugins/attribute_fu/lib/attribute_fu/associated_form_helper.rb:91:in `add_associated_link'
tobynet commented 14 years ago

This is patch (for Rails 2.3.5)

Index: C:/myproject/sample/vendor/plugins/attribute_fu/lib/attribute_fu/associated_form_helper.rb
===================================================================
--- C:/myproject/sample/vendor/plugins/attribute_fu/lib/attribute_fu/associated_form_helper.rb  (リビジョン 301)
+++ C:/myproject/sample/vendor/plugins/attribute_fu/lib/attribute_fu/associated_form_helper.rb  (作業コピー)
@@ -88,7 +88,9 @@
       form_builder     = self # because the value of self changes in the block

       function = "if (typeof #{variable} == 'undefined') #{variable} = 0; 
-                    $(#{container}).append($.template("+h([self.render_associated_form(object, :fields_for => { :javascript => true }, :partial => partial)].flatten.first.to_json)+"), { number: --#{variable}});"
+                    $(#{container}).append($.template("+
+        ApplicationController.helpers.send(:h, [self.render_associated_form(object, :fields_for => { :javascript => true }, :partial => partial)].flatten.first.to_json)+
+        "), { number: --#{variable}});"

       @template.link_to_function(name, function, opts)
     end