Sha256: bb44d281eb018d677a03ea8ea8ed8fe6612377f6f78750286791b457e97762cb

Contents?: true

Size: 592 Bytes

Versions: 1

Compression:

Stored size: 592 Bytes

Contents

module JqueryDynamicFieldsHelper
  module FieldHelper
    def link_to_add_fields name, f, association
      new_object = f.object.send(association).class.new
      id = new_object.object_id
      fields = f.fields_for(association, new_object, child_index: id) do |builder|
        render(association.to_s.singularize + "_fields", f: builder)
      end
      link_to(name, '#', class: "add_fields", data: {id: id, fields: fields.gsub("\n", "")})
    end

    def link_to_remove_field f
      (f.hidden_field :_destroy) +
        link_to("remove", "#", class: "remove_field")
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jquery_dynamic_fields-0.0.2 app/helpers/jquery_dynamic_fields/field_helper.rb