Message option for validation methods
Reported by Andrew Takahashi | May 5th, 2008 @ 07:14 AM
Hello,
I noticed that the validation methods (such as validates_attachment_size) don't let you override the error message with your own (e.g.: with ActiveRecord's validation methods you can add :message => 'your message' and you're good to go).
However, I did find a very simple way to add a message option to validates_attachment_size (can be the same for others).
Just add
options[:message] ||
to the beginning of line 156 in lib/paperclip.rb so it becomes:
options[:message] || "file size is not between #{options[:in].first} and #{options[:in].last} bytes."
This works very well for me, and I bet other users wouldn't mind this also. Could this be a possibility for the next release of Paperclip?
Comments and changes to this ticket
-
Jon Yurek May 5th, 2008 @ 05:01 PM
- → State changed from new to resolved
Funny you should mention this. I received a pull request this weekend from someone who added just this feature. It's in master right now, but it you want to wait for a release I should be tagging one in the next day or so.
Please Login or create a free account to add a new comment.
You can update this ticket by sending an email to from your email client. (help)
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
