Sha256: 3317f2a44bc12e3d3eade48774f403c91323c1c0b7e25a80d247f48a977eefb0

Contents?: true

Size: 860 Bytes

Versions: 1

Compression:

Stored size: 860 Bytes

Contents

module X
  module Editable
    module Rails
      module ViewHelpers  
        def editable model, object, method, options = {}
          if can? :edit, model and xeditable?
            model_name = model.to_s.downcase
            data_url = options[:nested_model] ? polymorphic_path([options[:nested_model], object]) : polymorphic_path(object)     
            content_tag :a, href: "#", class: "editable", data: { type: 'text', model: model_name, 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.0.0 lib/x-editable-rails/view_helpers.rb