Sha256: c1937da59a575c737d113b0500322465c9de55330dde77131645cb52ac1723c7

Contents?: true

Size: 709 Bytes

Versions: 4

Compression:

Stored size: 709 Bytes

Contents

#require 'rails_admin/config/fields/base'
module RailsAdmin::Config::Fields::Types
  class Uploader < RailsAdmin::Config::Fields::Types::Text
    RailsAdmin::Config::Fields::Types::register(:rails_uploader, self)

    register_instance_option(:config) do
      {}
    end

    register_instance_option(:partial) do
      :form_rails_uploader
    end

    def scope_type
      # Use association name if existent
      if bindings[:form].object_name.scan(/.*\[(.*)_attributes\]/).nil?
        bindings[:form].object_name
      else
        bindings[:form].object_name.scan(/.*\[(.*)_attributes\]/).to_s
      end
    end

    def scope_id
      bindings[:object].id
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
glebtv-rails-uploader-0.1.3 lib/uploader/rails_admin/field.rb
glebtv-rails-uploader-0.1.2 lib/uploader/rails_admin/field.rb
glebtv-rails-uploader-0.1.1 lib/uploader/rails_admin/field.rb
glebtv-rails-uploader-0.0.8 lib/uploader/rails_admin/field.rb