John Wong
2006-Jul-06 03:31 UTC
[RAILS] Help with overriding / overwriting date values in ActiveRecord to accept Euro Style Date from a Textbox
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
John Wong
2006-Jul-13 09:23 UTC
[RAILS] Help with overriding / overwriting date values in ActiveRecord to accept Euro Style Date from a Textbox
Anyone can help me out here? Still havent found the solution On 7/6/06, John Wong <john.wcl@gmail.com> wrote:> 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 >
Jonathan Viney
2006-Jul-13 12:26 UTC
[RAILS] Help with overriding / overwriting date values in ActiveRecord to accept Euro Style Date from a Textbox
Try my validates_date_time plugin, it should do what you need. http://svn.viney.net.nz/things/rails/plugins/validates_date_time -Jonathan. On 7/13/06, John Wong <john.wcl@gmail.com> wrote:> Anyone can help me out here? Still havent found the solution > > On 7/6/06, John Wong <john.wcl@gmail.com> wrote: > > 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 > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Matt Griffith
2006-Jul-13 13:17 UTC
[Rails] Re: Help with overriding / overwriting date values in Active
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 Griffith http://mattgriffith.net -- Posted via http://www.ruby-forum.com/.
John Wong
2006-Jul-18 07:37 UTC
[RAILS] Help with overriding / overwriting date values in ActiveRecord to accept Euro Style Date from a Textbox
Hi Jonathan, Thx a lot, Your plugin works perfectly! Really appreciate your help John On 7/13/06, Jonathan Viney <jonathan.viney@gmail.com> 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. > > On 7/13/06, John Wong <john.wcl@gmail.com> wrote: > > Anyone can help me out here? Still havent found the solution > > > > On 7/6/06, John Wong <john.wcl@gmail.com> wrote: > > > 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 > > > > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Jonathan Viney
2006-Jul-23 03:15 UTC
[Rails] Re: Help with overriding / overwriting date values in Active
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. On 7/14/06, Matt Griffith <mattgriffith-rubyforum@spamex.com> wrote:> 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 Griffith > http://mattgriffith.net > > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
nuno
2006-Jul-24 18:25 UTC
[Rails] Re: Help with overriding / overwriting date values in Active
Jonathan Viney 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 ! -- Posted via http://www.ruby-forum.com/.