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
17
18
19
20
# File 'lib/nested_form/view_helper.rb', line 13

def after_nested_form(association, &block)
  @associations ||= []
  @after_nested_form_callbacks ||= []
  unless @associations.include?(association)
    @associations << association
    @after_nested_form_callbacks << block
  end
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 |callback|
    callback.call
  end
  output << fields.join(" ").html_safe
end