Permalink
Browse files

Prevent Rails 1.8.x and REE from throwing errors on expected paramete…

…r for nested attributes
  • Loading branch information...
1 parent d5aa7fb commit 46e76583d91ac654d9e5229c1daccebba889e8d9 @mhuggins mhuggins committed Feb 15, 2012
Showing with 6 additions and 2 deletions.
  1. +6 −2 lib/formtastic/helpers/inputs_helper.rb
@@ -371,8 +371,12 @@ def inputs_for_nested_attributes(*args, &block) #:nodoc:
'but the block does not accept any argument.' if block.arity <= 0
lambda do |f|
contents = f.inputs(*args) do
- index = parent_child_index(options[:parent]) if options[:parent]
- block.call(f, index)
+ if block.arity == 1 # for backwards compatibility with REE & Ruby 1.8.x
+ block.call(f)
+ else
+ index = parent_child_index(options[:parent]) if options[:parent]
+ block.call(f, index)
+ end
end
template.concat(contents)
end

0 comments on commit 46e7658

Please sign in to comment.