Sha256: b54be7f2dd4eb3c0421ab3bcbdb9fb08c7a073d9b31a1126889367093865fb4f

Contents?: true

Size: 476 Bytes

Versions: 6

Compression:

Stored size: 476 Bytes

Contents

module Basepack
  module Forms
    module Fields
      class HasOneAssociation < Fields::SingleAssociation
        attr_default :editable, [:nested_form] do
          (nested_form || form.resource.respond_to?("#{name}_id=")) && super
        end

        attr_default :method_name, [:nested_form] do
          nested_form ? "#{name}_attributes".to_sym  : "#{name}_id".to_sym
        end

        def selected_id
          value.try :id
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
basepack-1.0.1 lib/basepack/forms/fields/has_one_association.rb
basepack-1.0.0 lib/basepack/forms/fields/has_one_association.rb
basepack-1.0.0.pre.0 lib/basepack/forms/fields/has_one_association.rb
basepack-0.2.0 lib/basepack/forms/fields/has_one_association.rb
basepack-0.1.0 lib/basepack/forms/fields/has_one_association.rb
basepack-0.0.2 lib/basepack/forms/fields/has_one_association.rb