From 1f62d1c39c3b90a3f71f7ffd3c07ced62dc3c50a Mon Sep 17 00:00:00 2001 From: Kir Shatrov Date: Thu, 18 Sep 2014 01:39:05 +0400 Subject: [PATCH] Fixed proc call when form with new record was initialized As I guess from `FormDefinition#initialize`, `proc` is never set. In my case, it was always `nil` and for new records, the code evaluated `form.instance_eval(&proc)` where `proc` was nil. That lead to `ArgumentError: wrong number of arguments (0 for 1..3)`. --- lib/active_form/form_collection.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/active_form/form_collection.rb b/lib/active_form/form_collection.rb index fe2f5cc..65cf92e 100644 --- a/lib/active_form/form_collection.rb +++ b/lib/active_form/form_collection.rb @@ -134,11 +134,11 @@ def aggregate_form_errors def fetch_models associated_records = parent.send(association_name) - + associated_records.each do |model| form = Form.new(association_name, parent, proc, model) forms << form - form.instance_eval &proc + form.instance_eval(&proc) if proc.present? end end @@ -146,7 +146,7 @@ def initialize_models records.times do form = Form.new(association_name, parent, proc) forms << form - form.instance_eval &proc + form.instance_eval(&proc) if proc.present? end end @@ -178,4 +178,4 @@ def create_form end end -end \ No newline at end of file +end