lib/attached/attachment.rb in attached-0.3.7 vs lib/attached/attachment.rb in attached-0.3.8

- old
+ new

@@ -18,10 +18,11 @@ attr_reader :instance attr_reader :queue attr_reader :purge attr_reader :errors attr_reader :path + attr_reader :missing attr_reader :styles attr_reader :default attr_reader :medium attr_reader :credentials attr_reader :processors @@ -39,10 +40,11 @@ # Attached::Attachment.options = { :storage => :fs, :path => ":name/:style/:identifier:extension" } def self.options @options ||= { :path => ":name/:style/:identifier:extension", + :missing => ":name/:style/missing:extension", :default => :original, :medium => :local, :credentials => {}, :styles => {}, :processors => [], @@ -78,10 +80,11 @@ @queue = {} @purge = [] @errors = [] @path = options[:path] + @missing = options[:missing] @styles = options[:styles] @default = options[:default] @medium = options[:medium] @credentials = options[:credentials] @processors = options[:processors] @@ -219,10 +222,10 @@ # @object.avatar.url # @object.avatar.url(:small) # @object.avatar.url(:large) def path(style = self.default) - path = @path.clone + path = self.attached? ? @path.clone : @missing.clone path.gsub!(/:name/, name.to_s) path.gsub!(/:style/, style.to_s) path.gsub!(/:extension/, extension(style).to_s) path.gsub!(/:identifier/, identifier(style).to_s) \ No newline at end of file