Permalink
Browse files

Workaround for dropping of concat()'s second arg.

The second argument (the binding) is deprecated since
Ruby on Rails 2.2.2.
  • Loading branch information...
1 parent f2af8eb commit 4e0852bf7a9c62d3f73b734255858fdeae5a1b8a @baldowl committed Mar 7, 2010
Showing with 16 additions and 2 deletions.
  1. +1 −0 lib/auto_admin_simple_theme.rb
  2. +15 −2 lib/declarative_form_builder.rb
@@ -231,6 +231,7 @@ def inner_fields_for(inner_object_name, inner_object)
def table_fields_for(inner_object_name, inner_object, extra_options={}, &proc)
options = @options.dup
options[:inner_builder] = options.delete(:table_builder)
+ # Superfluous since Rails 2.2.2; let's keep it for 2.1.*.
options[:binding] ||= @proc.binding
options.update extra_options
@template.fields_for( "#{@object_name}_#{inner_object_name}", inner_object, @template, options ) do |i|
@@ -1,8 +1,14 @@
class DeclarativeFormBuilder
def initialize(object_name, object, erb_self, options, proc)
+ # @binding is superfluous since Rails 2.2.2; let's keep it for 2.1.*.
@erb, @binding, @options = erb_self, options[:binding] || proc.binding, options
@inner = (options[:inner_builder] || ActionView::Helpers::FormBuilder).new(object_name, object, erb_self, options, proc)
- @erb.concat("\n", @binding)
+ # concat()'s second argument is deprecated since Rails 2.2.2.
+ if @erb.method(:concat).arity == 2
+ @erb.concat("\n", @binding)
+ else
+ @erb.concat("\n")
+ end
end
%w(object inner_fields_for table_fields_for with_object).each do |meth|
class_eval <<-end_src, __FILE__, __LINE__
@@ -29,6 +35,13 @@ def method_missing(method, *args, &block)
end
def buffer!(content)
pre = @options[:indent] ? (' ' * @options[:indent]) : ''
- @erb.concat(pre + content + "\n", @binding) if content && content != ''
+ if content && content != ''
+ # concat()'s second argument is deprecated since Rails 2.2.2.
+ if @erb.method(:concat).arity == 2
+ @erb.concat(pre + content + "\n", @binding)
+ else
+ @erb.concat(pre + content + "\n")
+ end
+ end
end
end

0 comments on commit 4e0852b

Please sign in to comment.