class Resourceable::Inputs::HasManyInput

Public Instance Methods

input() click to toggle source
# File lib/resourceable/inputs/has_many.rb, line 5
def input 
  unless partial 
    # TODO: Implement proper exceptions.
    raise 'You must specify a partial for `has_many` inputs.'
  end
  output = ActiveSupport::SafeBuffer.new 

  output << @builder.simple_fields_for(attribute_name )do |ff|
    ff.input(:id, as: :hidden) + build_inputs(ff)
  end

  output
end

Private Instance Methods

action_view() click to toggle source
# File lib/resourceable/inputs/has_many.rb, line 25
def action_view 
  @action_view ||= ActionView::Base.new(ActionController::Base.view_paths, {})
end
build_inputs(form_object) click to toggle source
# File lib/resourceable/inputs/has_many.rb, line 29
def build_inputs(form_object)
  action_view.render(partial: partial, locals: { form_object: form_object }).html_safe
end
partial() click to toggle source
# File lib/resourceable/inputs/has_many.rb, line 21
def partial 
  options.fetch(:partial, nil)
end