Sha256: 2244532f867120539c90f41f82044eefbf4e558e83e7ec4a76d0f60a3a209c4f

Contents?: true

Size: 677 Bytes

Versions: 1

Compression:

Stored size: 677 Bytes

Contents

module Para
  module Inputs
    class NestedOneInput < SimpleForm::Inputs::Base
      def input(wrapper_options = nil)
        input_html_options[:class] << "nested-one"

        parent_model = object.class
        model = parent_model.reflect_on_association(attribute_name).klass
        resource = object.send(:"#{ attribute_name }") ||
                    object.send(:"#{ attribute_name }=", model.new)

        template.render(
          partial: 'para/inputs/nested_one',
          locals: {
            form: @builder,
            model: model,
            resource: resource,
            attribute_name: attribute_name
          }
        )
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
para-0.4.0 lib/para/inputs/nested_one_input.rb