module AttachmentHelper
Attachment Helper
Specify some attachment reader:
# avatar_path: a string # pdf_paths: a array of string has_attachments :avatar_path, :pdf_paths # or has_attachments [:avatar_path, {size: '100x100'}], :pdf_paths
Generated Methods:
avatar_url avatar_filename pdf_urls pdf_filenames
Constants
- VERSION
Attributes
attachment_host[RW]
Public Class Methods
get_filename_by_path(path)
click to toggle source
# File lib/attachment_helper.rb, line 35 def get_filename_by_path(path) return if path.nil? path.split('/').last end
get_url_by_path(path, options = {})
click to toggle source
# File lib/attachment_helper.rb, line 25 def get_url_by_path(path, options = {}) return if path.nil? query = options.empty? ? '' : "?#{URI.encode_www_form(options)}" if path =~ /^http/ "#{path}#{query}" else "#{AttachmentHelper.attachment_host}/#{path}#{query}" end end
included(cls)
click to toggle source
# File lib/attachment_helper.rb, line 12 def included(cls) cls.extend(AttachmentHelper::ClassMethods) end
symbolize_keys(hash)
click to toggle source
# File lib/attachment_helper.rb, line 21 def symbolize_keys(hash) hash.each_with_object({}) {|kv, r| r[(kv.first.to_sym rescue kv.first)] = kv.last } end