Florent Guiliani
2009-Feb-17 10:04 UTC
Assign sysdate instead of the result of DateTime::now()
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,
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
jemminger
2009-Feb-17 15:48 UTC
Re: Assign sysdate instead of the result of DateTime::now()
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...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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,--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---