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
Anyone can help me out here? Still havent found the solution
Try my validates_date_time plugin, it should do what you need.
http://svn.viney.net.nz/things/rails/plugins/validates_date_time
-Jonathan.
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
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
Hi Jonathan,
Thx a lot,
Your plugin works perfectly! Really appreciate your help
John
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
-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 !
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.