Last active
December 24, 2015 11:29
-
-
Save Archimidis/6791103 to your computer and use it in GitHub Desktop.
Paperclip wrong attachment url on validation errors: http://stackoverflow.com/a/5995636/2425581
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class ModelName | |
| # declare papaerclip :avatar file | |
| # ... | |
| after_validation :avatar_reverted? | |
| def avatar_reverted? | |
| unless self.errors[:avatar_file_size].blank? or self.errors[:avatar_content_type].blank? | |
| self.avatar.instance_write(:file_name, self.avatar_file_name_was) | |
| self.avatar.instance_write(:file_size, self.avatar_file_size_was) | |
| self.avatar.instance_write(:content_type, self.avatar_content_type_was) | |
| end | |
| end | |
| # ... | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment