Forum: Ruby on Rails Assign sysdate instead of the result of DateTime::now()

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
93ad2a2e46d53c10bf8789e3dae7b325?d=identicon&s=25 Florent Guiliani (Guest)
on 2009-02-17 11:44
(Received via mailing list)
Hi rails devs,

I've put the following code in a model:

    protected
      def validate
        self[:lastupdate] = DateTime::now()
      end

I wonder how I could get "sysdate" instead of the result of
DateTime::now() in the generated SQL request. The goal is to get the
database server time and not the application server time. You've
already figure out that I'm using Oracle ;).

I have 2 solutions:
   - hack quote() into OracleAdapter
   - add a trigger directly on the oracle table

Is somebody would have a better solution?

Regards,
--
Florent,
D69d23d8e811e8ab2a8593380d6ede63?d=identicon&s=25 Jeff Emminger (jemminger)
on 2009-02-17 16:49
(Received via mailing list)
Is the issue that the app server time is inconsistent with the
database server, or is it a time zone issue?  If it's the latter, I
would suggest you store all dates as GMT and just let rails set
created_at and updated_at for you automatically.


On Feb 17, 5:04 am, Florent Guiliani <florent.guili...@gmail.com>
This topic is locked and can not be replied to.