lib/dejavu.rb in dejavu-0.1.1 vs lib/dejavu.rb in dejavu-0.1.2

- old
+ new

@@ -5,11 +5,11 @@ def has_dejavu?(obj) obj_name = ActiveRecord::Base === obj ? obj.class.model_name.underscore : obj.to_s !!flash[:"saved_#{obj_name}_for_redisplay"] end - def get_dejavu_for(obj) + def get_dejavu_for(obj, opts = {}) is_instance = ActiveRecord::Base === obj model_name = is_instance ? obj.class.model_name.underscore : obj.to_s if has_dejavu?(obj) foo = if is_instance @@ -21,9 +21,16 @@ obj else obj.to_s.classify.constantize.new flash[:"saved_#{model_name}_for_redisplay"] end foo.valid? + + if opts[:exclude_errors_on] + [opts[:exclude_errors_on]].flatten.each do |attr| + foo.errors.delete(attr) + end + end + foo else is_instance ? obj : obj.to_s.classify.constantize.new end end