On Sat, Dec 19, 2009 at 12:42 PM, hendra kusuma <[email protected]>wrote:
> > > On Sat, Dec 19, 2009 at 10:55 AM, Jeremy Evans <[email protected]>wrote: > >> On Dec 18, 6:58 pm, hendra kusuma <[email protected]> wrote: >> > Dear all, Another question >> > >> > I have been trying to save a data in format Date >> > use postgresql 8 >> > I use 3 textbox to catch day, month, year >> > for then combined into 1 string >> > >> > My code is like this >> > a = Model.new >> > a.birth = Time.parse('some-date-in-string') >> > a.save >> > >> > When I input something like '1900-1-1' >> > it does not save anything >> > >> > I know this is not sequel issue, for this >> > behavior is based on Time class >> > that cannot parse a less then a certain year >> > I googled once and found a little variety of those year limit >> > >> > What I ask is, >> > probably some of you already find a work around to solve this problem >> > maybe you can share? >> >> Sequel.datetime_class = DateTime >> a = Model.create(:birth=>'some-date-in-string') >> >> > really sorry, I don't understand your example (I am still learning to read > the docs) > are you suggesting that I use Model.create with parameter to insert? > the reason I use .new is because I tried to insert to many fields (> 10) > and having 10 parameters over .create is not fun to do :) > > or are you suggesting other? > > -- > OK. I get it Do it like this a = Model.create |record| record.birth = "#{y}-#{m}-#{d}" end It works perfectly Thanks -- Suka linux? Kunjungi blog saya http://penguinroad.blogspot.com -- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/sequel-talk?hl=en.
