Hi, I have an ''updated_at'' field in events table. Whenever I am creating an event it gets set to Time.now. But I don''t want to set current time in it. But I want to set another time. How should I do that? I tried like this:- event.updated_at="2008-02-02 03:35:11". event.save Still it not working. Can anyone tell me how to do that? Thanks, Tushar -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
You can''t without executing the sql directly, because updated at is automagic Sent from my iPhone On 02/02/2009, at 9:19 PM, Tushar Gandhi <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org > wrote:> > Hi, > I have an ''updated_at'' field in events table. Whenever I am creating > an event it gets set to Time.now. But I don''t want to set current time > in it. But I want to set another time. How should I do that? I tried > like this:- > > event.updated_at="2008-02-02 03:35:11". > event.save > > Still it not working. > Can anyone tell me how to do that? > Thanks, > Tushar > -- > Posted via http://www.ruby-forum.com/. > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
you can try overriding the method that is setting the updated_at attribute. take a look at this (which is the first hit google found for me on that subject): http://neeraj.name/blog/articles/800-override-automatic-timestamp-in-activerecrod-rails --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Mon, Feb 2, 2009 at 12:19 PM, Tushar Gandhi < rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Hi, > I have an ''updated_at'' field in events table. Whenever I am creating > an event it gets set to Time.now. But I don''t want to set current time > in it. But I want to set another time. How should I do that? I tried > like this:- > > event.updated_at="2008-02-02 03:35:11". > event.save > > Still it not working. > Can anyone tell me how to do that? > Thanks, > Tushar > -- > Posted via http://www.ruby-forum.com/. > > > >Think about why you want to do this. The updated_at column is an automatic column that is meant to provide the date and time the entry was last modified. If you need to set a different date/time, why not create a new field with a new name and then set it manually or you can auto set it in a before_save method with your own business logic. -- Andrew Timberlake http://ramblingsonrails.com http://www.linkedin.com/in/andrewtimberlake "I have never let my schooling interfere with my education" - Mark Twain --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
MaD wrote:> you can try overriding the method that is setting the updated_at > attribute. take a look at this (which is the first hit google found > for me on that subject): > http://neeraj.name/blog/articles/800-override-automatic-timestamp-in-activerecrod-railsThat seems to be not working for me. I have column name as "date_modified" instead of "updated_at". I done everything that is given their. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---