Sha256: 1f8d58630d765e7e67a8da3fa510d90f735b235d78bb6268f4b545b3f6144614

Contents?: true

Size: 787 Bytes

Versions: 3

Compression:

Stored size: 787 Bytes

Contents

module Abracadabra
  module Rails
    module ViewHelper
      def click_to_edit(instance, options)
        instance_class = instance.class.to_s.underscore
        link_class = "#{options[:class]} abracadabra".strip
        value = options[:value] || instance.send(options[:attribute])
        method = options[:method] || "patch"

        if !options[:remote].nil? && options[:remote] == false
          remote = false
        else
          remote = true
        end

        data_type = options[:type].to_s.gsub(/^j+s+$/, "script") || "script"

        link_to value, "javascript:void(0)", class: link_class, method: method.to_sym, data: { path: options[:path], attribute: options[:attribute], class: instance_class, type: data_type.to_sym }, remote: remote
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
abracadabra-1.0.5 app/helpers/abracadabra/rails/view_helper.rb
abracadabra-1.0.4 app/helpers/abracadabra/rails/view_helper.rb
abracadabra-1.0.3 app/helpers/abracadabra/rails/view_helper.rb