Sha256: b3676b979b9da1d5adf44c6f738199ff1b1ac8ebe34e4e1fb51ecfa95e765c59

Contents?: true

Size: 915 Bytes

Versions: 1

Compression:

Stored size: 915 Bytes

Contents

module X
  module Editable
    module Rails
      module ViewHelpers  
        def editable model, object, method, options = {}
          if can? :edit, model and xeditable?
            data_url = polymorphic_path(object)
            object = object.last if object.kind_of?(Array)
            model_param = model.to_s.downcase.gsub('::', '_')
            model_name = model.to_s.downcase.gsub('::', '/')
            content_tag :a, href: "#", class: "editable", data: { type: 'text', model: model_param, name: method, url: data_url, 
              nested: (options[:nested] if options[:nested]), nid: (options[:nid] if options[:nid]), 'original-title' => t("activerecord.attributes.#{model_name}#{"/#{options[:nested].singularize}" if options[:nested]}.#{method}") } do
                object.send(method) 
            end
          else
            options[:e]
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
x-editable-rails-1.1.0 lib/x-editable-rails/view_helpers.rb