# Validates\_presence\_of validating twice?

**URL:** <https://www.ruby-forum.com/t/validates-presence-of-validating-twice/117534>\
**Category:** Rails\
**Created:** [October 17, 2007, 9:05pm UTC](https://www.ruby-forum.com/t/validates-presence-of-validating-twice/117534 "2007-10-17T21:05:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![steve](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f19dbf/32.png) [@steve](https://www.ruby-forum.com/u/steve)\
**Post date:** [October 17, 2007, 9:05pm UTC](https://www.ruby-forum.com/t/validates-presence-of-validating-twice/117534/1 "2007-10-17T21:05:32Z")

</div>

I’m getting some weird behavior in one of my models. I have a model  
defined something like this

class User \< ActiveRecord::Base  
attr\_accessor :password

validates\_presence\_of :password  
end

If I validate the model without specifying a password, I get [“can’t be  
blank”, “can’t be blank”] for :password instead of just one “cant’t be  
blank”. If I comment out the validates\_presence\_of statement, then no  
errors. So it doesn’t seem like it’s being defined elsewhere(though a  
plugin or some such). Any idea what might be going on here?

Thanks,  
Steve

---

<div class="post-metadata">

**Author:** ![steve](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f19dbf/32.png) [@steve](https://www.ruby-forum.com/u/steve)\
**Post date:** [October 17, 2007, 9:17pm UTC](https://www.ruby-forum.com/t/validates-presence-of-validating-twice/117534/2 "2007-10-17T21:17:15Z")

</div>

When you call the page, do you use a request.post?

---

<div class="post-metadata">

**Author:** ![steve](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f19dbf/32.png) [@steve](https://www.ruby-forum.com/u/steve)\
**Post date:** [October 17, 2007, 10:28pm UTC](https://www.ruby-forum.com/t/validates-presence-of-validating-twice/117534/3 "2007-10-17T22:28:43Z")

</div>

On 10/17/07, Steve [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> If I validate the model without specifying a password, I get [“can’t be  
> blank”, “can’t be blank”] for :password instead of just one “cant’t be  
> blank”. If I comment out the validates\_presence\_of statement, then no  
> errors. So it doesn’t seem like it’s being defined elsewhere(though a  
> plugin or some such). Any idea what might be going on here?

This can happen if the model file gets loaded twice. Do you have

require ‘user’

somewhere in your code?

---

<div class="post-metadata">

**Author:** ![steve](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f19dbf/32.png) [@steve](https://www.ruby-forum.com/u/steve)\
**Post date:** [October 18, 2007, 6:47am UTC](https://www.ruby-forum.com/t/validates-presence-of-validating-twice/117534/4 "2007-10-18T06:47:54Z")

</div>

On Wed, 17 Oct 2007 16:28:18 -0400, Bob S. wrote:

> This can happen if the model file gets loaded twice. Do you have
> 
> require ‘user’
> 
> somewhere in your code?

Yes, I had a “load” statement in there that was causing this to happen.  
Thanks.
