cirandas.net

ref: master

app/models/concerns/postgresql_attachment_fu.rb


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
module PostgresqlAttachmentFu

  module ClassMethods
    def postgresql_attachment_fu
      send :include, InstanceMethods
    end
  end

  module InstanceMethods
    def full_filename(thumbnail = nil)
      file_system_path = (thumbnail ? thumbnail_class : self).attachment_options[:path_prefix].to_s
      file_system_path = File.join(file_system_path, ActiveRecord::Base.connection.schema_search_path) if Noosfero::MultiTenancy.on?
      Rails.root.join(file_system_path, *partitioned_path(thumbnail_name_for(thumbnail))).to_s
    end
  end

end