Conditional Validation with Paperclip difficult
Posted
by Michael Schmitz
on Stack Overflow
See other posts from Stack Overflow
or by Michael Schmitz
Published on 2010-04-07T19:08:18Z
Indexed on
2010/04/07
19:13 UTC
Read the original article
Hit count: 486
Hi,
I have an "item", which goes through a multi-page creation process. Images are uploaded at step five, and I keep track of the steps by using the attribute "complete". When validating whether an image is attached with paperclip, I get problems using the code below:
validates_attachment_presence :pic1, :if => Proc.new { |u| u.complete == "step5"}
It seems that I can't access the "complete" attribute, as the active-record object seems to be the paperclip image. Is there a way for me to check at which point in the process I am and validate conditionally?
Thanks, Michael
© Stack Overflow or respective owner