# encoding: UTF-8 module AttachmentMagick::AttachmentMagickHelper def attachment_progress_container(object, data_type="images") unless object.new_record? obj = object key = "#{object.class.to_s.underscore}_#{object.id}" if obj.respond_to?(:embedded?) if obj.embedded? embedded_in = obj.relations.values.select { |x| x.macro == :embedded_in}.first parent = embedded_in.class_name parent_id = obj._parent.id.to_s inverse_of = embedded_in.inverse_of text_eval = "#{parent}_#{parent_id}_#{inverse_of}_#{obj.id.to_s}" end end data_attachment = text_eval.blank? ? "#{object.class}_#{object.id}" : text_eval html = %{
} html.html_safe end end def attachment_for_view(object, partial = nil, collection=nil, use_sortable=true) unless object.new_record? unless collection.present? if AttachmentMagick.configuration.orms.include?("Mongoid") if object.class.include?(Mongoid::Document) collection = object.images.order_by(:priority.asc) end end if AttachmentMagick.configuration.orms.include?("ActiveRecord") if object.class.include?(ActiveRecord::Persistence) collection = object.images.order(:priority) end end end key = "#{object.class.to_s.underscore}_#{object.id}" html_partial = "" if partial html = render(:partial => partial || AttachmentMagick.configuration.default_add_partial, :collection => collection, :as =>:image) "#{html_partial}