lib/attached.rb in attached-0.2.9 vs lib/attached.rb in attached-0.3.0
- old
+ new
@@ -147,14 +147,16 @@
# validates_attached_extension :avatar, :in => %w(png jpg), :message => "extension must be :in"
def validates_attached_extension(name, options = {})
message = options[:message]
- message ||= "extension must be specified"
+ message ||= "extension is not valid"
- range = options[:in].map { |element| /element/ }
+ range = options[:in].map { |element| ".#{element}" }
+ validates_inclusion_of :"#{name}_extension", :message => message,
+ :if => options[:if], :unless => options[:unless]
end
# Validates that an attachment is included.
#
@@ -167,10 +169,11 @@
# validates_attached_presence :avatar
# validates_attached_presence :avatar, :message => "must be attached"
def validates_attached_presence(name, options = {})
- message = options[:message] || "must be attached"
+ message = options[:message]
+ message ||= "must be attached"
validates_presence_of :"#{name}_identifier", :message => message,
:if => options[:if], :unless => options[:unless]
end
\ No newline at end of file