lib/attach_it/attach_it.rb in mm-attach-it-0.1.2 vs lib/attach_it/attach_it.rb in mm-attach-it-0.1.3
- old
+ new
@@ -5,11 +5,11 @@
end
end
module ClassMethods
def has_attachment(name, options = {})
- options.symbolize_keys!
+ options = options.symbolize_keys
name = name.to_sym
after_save :save_attachments
before_destroy :destroy_attachments
@@ -23,11 +23,11 @@
end
define_method("#{name}") do
information_for(name, options)
end
-
+
validates_each name, :logic => lambda { information_for(name, options).send(:flush_errors) }
end
def validates_attachment_size(name = nil, options = {})
min = options[:greater_than] || (options[:in] && options[:in].first) || 0
@@ -72,11 +72,13 @@
@attachment_options[name].save
end
end
def destroy_attachments
- @attachment_options.keys.each do |name|
- @attachment_options[name].delete
+ unless @attachment_options.nil?
+ @attachment_options.keys.each do |name|
+ @attachment_options[name].delete
+ end
end
end
end
end