# Help with overriding / overwriting date values in ActiveReco

**URL:** <https://www.ruby-forum.com/t/help-with-overriding-overwriting-date-values-in-activereco/97292>\
**Category:** Rails\
**Created:** [July 6, 2006, 5:33am UTC](https://www.ruby-forum.com/t/help-with-overriding-overwriting-date-values-in-activereco/97292 "2006-07-06T05:33:55Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![John\_Wong](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/6f9a4e/32.png) [@John\_Wong](https://www.ruby-forum.com/u/John_Wong)\
**Post date:** [July 6, 2006, 5:33am UTC](https://www.ruby-forum.com/t/help-with-overriding-overwriting-date-values-in-activereco/97292/1 "2006-07-06T05:33:55Z")

</div>

Hi guys,

I’m trying to make an AR model which accepts a string data (from a  
text input) in euro date format

eg  
\<input … value = “23/01/2006”\> ( 23 Jan 2006)

Reading the example from RDoc… i tried to  
overwrite/overload/override the = function to write in the date…

Cant get it to work because … i dont knoe what format should it  
accept… i’ve tried hardcoding things like below but it all doesnt  
work…  
i) “2006-01-23”  
i) “2006-01-23”.to\_date  
i) Time.now

Any ideas anyone?

Eg code

```
def install_date=(newdate)
  write_attribute(:install_date, "2006-01-23")
end

```

John W

---

<div class="post-metadata">

**Author:** ![John\_Wong](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/6f9a4e/32.png) [@John\_Wong](https://www.ruby-forum.com/u/John_Wong)\
**Post date:** [July 13, 2006, 11:26am UTC](https://www.ruby-forum.com/t/help-with-overriding-overwriting-date-values-in-activereco/97292/2 "2006-07-13T11:26:52Z")

</div>

Anyone can help me out here? Still havent found the solution

---

<div class="post-metadata">

**Author:** ![John\_Wong](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/6f9a4e/32.png) [@John\_Wong](https://www.ruby-forum.com/u/John_Wong)\
**Post date:** [July 13, 2006, 2:29pm UTC](https://www.ruby-forum.com/t/help-with-overriding-overwriting-date-values-in-activereco/97292/3 "2006-07-13T14:29:40Z")

</div>

Try my validates\_date\_time plugin, it should do what you need.

[http://svn.viney.net.nz/things/rails/plugins/validates\_date\_time](http://svn.viney.net.nz/things/rails/plugins/validates_date_time)

-Jonathan.

---

<div class="post-metadata">

**Author:** ![John\_Wong](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/6f9a4e/32.png) [@John\_Wong](https://www.ruby-forum.com/u/John_Wong)\
**Post date:** [July 13, 2006, 3:17pm UTC](https://www.ruby-forum.com/t/help-with-overriding-overwriting-date-values-in-activereco/97292/4 "2006-07-13T15:17:42Z")

</div>

John Wong,

> Try my validates\_date\_time plugin, it should do what you need.

This probably won’t affect you since you won’t be using us\_date\_format =  
true, but for others there is one issue with validates\_date\_time. I  
discussed it here:

Dates loaded from the database are not valid when using  
validates\_date\_time with us\_date\_format  
[http://mattgriffith.net/PermaLink.aspx?guid=4740f630-85db-4a4c-b199-8445b345f4f4](http://mattgriffith.net/PermaLink.aspx?guid=4740f630-85db-4a4c-b199-8445b345f4f4)

Basically if you are using us\_date\_format = true the validates\_date\_time  
plugin may not recognize dates loaded from the database.

Otherwise validates\_date\_time is a wonderful solution for pragmatic date  
entry.

Matt G.  
[http://mattgriffith.net](http://mattgriffith.net)

---

<div class="post-metadata">

**Author:** ![John\_Wong](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/6f9a4e/32.png) [@John\_Wong](https://www.ruby-forum.com/u/John_Wong)\
**Post date:** [July 18, 2006, 9:39am UTC](https://www.ruby-forum.com/t/help-with-overriding-overwriting-date-values-in-activereco/97292/5 "2006-07-18T09:39:48Z")

</div>

Hi Jonathan,

Thx a lot,  
Your plugin works perfectly! Really appreciate your help

John

---

<div class="post-metadata">

**Author:** ![John\_Wong](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/6f9a4e/32.png) [@John\_Wong](https://www.ruby-forum.com/u/John_Wong)\
**Post date:** [July 24, 2006, 8:25pm UTC](https://www.ruby-forum.com/t/help-with-overriding-overwriting-date-values-in-activereco/97292/6 "2006-07-24T20:25:15Z")

</div>

Jonathan V. wrote:

> Try my validates\_date\_time plugin, it should do what you need.
> 
> [http://svn.viney.net.nz/things/rails/plugins/validates\_date\_time](http://svn.viney.net.nz/things/rails/plugins/validates_date_time)
> 
> -Jonathan.

I love the magic that goes with every rails side project ! So many times  
I don’t spend reinventing the wheel, while using somebody others wheels  
is so so easy and efficient !

Thanks a lot Jonathan !

---

<div class="post-metadata">

**Author:** ![John\_Wong](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/6f9a4e/32.png) [@John\_Wong](https://www.ruby-forum.com/u/John_Wong)\
**Post date:** [July 23, 2006, 5:19am UTC](https://www.ruby-forum.com/t/help-with-overriding-overwriting-date-values-in-activereco/97292/7 "2006-07-23T05:19:56Z")

</div>

The problems with us\_date\_format were fixed a couple of days after  
your blog post when someone reported them to me. Everything should be  
fine now.

-Jonathan.
