lib/attached.rb in attached-0.0.2 vs lib/attached.rb in attached-0.0.3
- old
+ new
@@ -34,14 +34,15 @@
# * :styles -
# * :storage -
#
# Usage:
#
- # has_attached :avatar
- # has_attached :avatar, :storage => :s3
- # has_attached :clip, styles => [ :mp4, :ogv ]
- # has_attached :clip, styles => { :main => { :size => "480p", :format => "mp4" } }
+ # has_attached :video
+ # has_attached :video, :storage => :s3
+ # has_attached :video, styles => [ :mp4, :ogv ]
+ # has_attached :video, styles => { :main => { :size => "480p", :format => "mp4" } }
+ # has_attached :thumbnail, :range => (1..4)
def has_attached(name, options = {})
include InstanceMethods
@@ -71,12 +72,17 @@
self.errors[:"#{name}_extension"].each do |message|
self.errors.add(name, message)
end
+ self.errors[:"#{name}_identifier"].each do |message|
+ self.errors.add(name, message)
+ end
+
self.errors.delete(:"#{name}_size")
self.errors.delete(:"#{name}_extension")
+ self.errors.delete(:"#{name}_identifier")
end
end
@@ -127,10 +133,10 @@
def validates_attached_presence(name, options = {})
message = options[:message] || "must be attached"
- validates_presence_of :"#{name}_extension", :message => message,
+ validates_presence_of :"#{name}_identifier", :message => message,
:if => options[:if], :unless => options[:unless]
end
\ No newline at end of file