Class: Interview::PolymorphicNestedFormAddLink

Inherits:
Control
  • Object
show all
Defined in:
lib/interview/controls/polymorphic_nested_form_add_link.rb

Overview

todo

Instance Attribute Summary collapse

Attributes inherited from Control

#parent

Instance Method Summary collapse

Methods inherited from Control

#ancestors, #build_child, #build_with_params, #find_attribute, #find_attribute!, #initialize, #set_attributes, #set_defaults

Constructor Details

This class inherits a constructor from Interview::Control

Instance Attribute Details

#polymorphic_classesObject

todo



4
5
6
# File 'lib/interview/controls/polymorphic_nested_form_add_link.rb', line 4

def polymorphic_classes
  @polymorphic_classes
end

Instance Method Details

#build(b) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/interview/controls/polymorphic_nested_form_add_link.rb', line 6

def build(b)
  form_builder = find_attribute! :form_builder
  assoc_method = find_attribute!(:assoc_method).to_sym
  if @polymorphic_classes
    build_polymorphic_link(b, form_builder, assoc_method)
  else
    text = h.t('views.nested_form_add', association: find_attribute!(:singular_title))
    html = render_form(form_builder, assoc_method)
    b.link capion: text, html_options: { href: '#', class: 'nested_form_add_link', data: { content: CGI::escapeHTML(html) } }
  end
end