Module: NestedForm::ViewHelper

Included in:
ActionView::Base
Defined in:
lib/nested_form/view_helper.rb

Instance Method Summary collapse

Instance Method Details

#after_nested_form(association, &block) ⇒ Object



13
14
15
16
# File 'lib/nested_form/view_helper.rb', line 13

def after_nested_form(association, &block)
  @after_nested_form_callbacks ||= {}
  @after_nested_form_callbacks[association] = block
end

#nested_form_for(*args, &block) ⇒ Object



3
4
5
6
7
8
9
10
11
# File 'lib/nested_form/view_helper.rb', line 3

def nested_form_for(*args, &block)
  options = args.extract_options!.reverse_merge(:builder => NestedForm::Builder)
  output = form_for(*(args << options), &block)
  @after_nested_form_callbacks ||= {}
  fields = @after_nested_form_callbacks.map do |key, callback|
    callback.call
  end
  output << fields.join(" ").html_safe
end