Sha256: a1493e8460dfb6eff1336326a9603dcd5f4aa7fe839ba19d6c64fc477d7fba7d

Contents?: true

Size: 590 Bytes

Versions: 11

Compression:

Stored size: 590 Bytes

Contents

module Para
  module Admin
    module NestedInputsHelper
      # Helper that allows filling a parent association for a given resource, based on the
      # inverse_of option of the parent resource association.
      #
      def with_inverse_association_for(resource, attribute_name, parent_resource)
        resource.tap do
          association_name = parent_resource.association(attribute_name).options[:inverse_of]
          return resource unless association_name

          resource.association(association_name).send(:replace, parent_resource)
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
para-0.12.4 app/helpers/para/admin/nested_inputs_helper.rb
para-0.12.3 app/helpers/para/admin/nested_inputs_helper.rb
para-0.12.2 app/helpers/para/admin/nested_inputs_helper.rb
para-0.12.1 app/helpers/para/admin/nested_inputs_helper.rb
para-0.12.0 app/helpers/para/admin/nested_inputs_helper.rb
para-0.11.4 app/helpers/para/admin/nested_inputs_helper.rb
para-0.11.3 app/helpers/para/admin/nested_inputs_helper.rb
para-0.11.2 app/helpers/para/admin/nested_inputs_helper.rb
para-0.11.1 app/helpers/para/admin/nested_inputs_helper.rb
para-0.11.0 app/helpers/para/admin/nested_inputs_helper.rb
para-0.10.0 app/helpers/para/admin/nested_inputs_helper.rb