Steven Talcott Smith
2006-Sep-11 14:41 UTC
Help: Timestamp and Userstamp just stopped working
Uh oh. I am going to have a nightmare cleaning this up... It looks like timestamp and userstamp just stopped doing their thing. Across several different models, I am seeing NULLs in my database for updated_by and updated_at and created_at/etc. Last night, I ran a migration that turned userstamp and timestamp off for two different models using the class attribute accessor. I have since restarted the production server so there should be no lasting effect from this. This problem is affecting models which had nothing to do with the migration. Has anyone heard of something like this? I shudder to think of the mess this will create in my database today -- a Monday -- our heaviest day. I will have 500+ users through the site today plus my staff working on content all day. Ugh. Any ideas where to look? I looked at the source for both of these and they are so simple I don''t see how they would just break like that. Steven -- 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 -~----------~----~----~----~------~----~------~--~---
Steven Talcott Smith
2006-Sep-11 15:35 UTC
Re: Help: Timestamp and Userstamp just stopped working
Steven Talcott Smith wrote:> Uh oh. I am going to have a nightmare cleaning this up... It looks > like timestamp and userstamp just stopped doing their thing. > > Across several different models, I am seeing NULLs in my database for > updated_by and updated_at and created_at/etc.Okay, Lesson Learned! Class attribute accessors can be called on an instance. Do not call my_model.record_timestamps = false unless you want to turn this behavior off system-wide. Two things: 1) the documentation on Timestamp should explain more clearly that setting applies to ActiveRecord::Base... not the class of your model and certainly not the instance. 2) I think this violates the "do the expected thing" principle. Does anyone agree? Thank goodness for open source. I was able to contain the damage once I saw the problem and removed the offending line from my code. May google save this and help someone else to avoid the same problem. Now, to clean up those NULLs.... Best, Steven -- 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 -~----------~----~----~----~------~----~------~--~---
Steven Talcott Smith wrote:> Do not call my_model.record_timestamps = false unless you want to turn > this behavior off system-wide.Interesting. What you want should certainly be possible. This is what I found in the documentation (http://caboo.se/doc/classes/ActiveRecord/Timestamp.html): {snip} Keep in mind that, via inheritance, you can turn off timestamps on a per model basis by setting record_timestamps to false in the desired models. class Feed < ActiveRecord::Base self.record_timestamps = false # ... end {snip} Try doing this and see if it helps (on your development box :-) I''m not sure why doing "self." would be different from what you did, though...? Jeff softiesonrails.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 -~----------~----~----~----~------~----~------~--~---
Steven Talcott Smith
2006-Sep-11 22:39 UTC
Re: Help: Timestamp and Userstamp just stopped working
Jeff Cohen wrote:> Steven Talcott Smith wrote: >> Do not call my_model.record_timestamps = false unless you want to turn >> this behavior off system-wide. > > Interesting. What you want should certainly be possible....> > I''m not sure why doing "self." would be different from what you did, > though...?I need to read up on the subtleties of "self." since I am unclear on the implications. I have used it inconsistently in my code so far. Any good pointers? I will check pickaxe tomorrow. Steven -- 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 -~----------~----~----~----~------~----~------~--~---
On 9/11/06, Steven Talcott Smith <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Jeff Cohen wrote: > > Steven Talcott Smith wrote: > >> Do not call my_model.record_timestamps = false unless you want to turn > >> this behavior off system-wide. > > > > Interesting. What you want should certainly be possible. > ... > > > > I''m not sure why doing "self." would be different from what you did, > > though...? > > I need to read up on the subtleties of "self." since I am unclear on the > implications. I have used it inconsistently in my code so far. Any > good pointers? I will check pickaxe tomorrow.The best coverage of that topic that I''ve seen so far has been in Ruby for Rails. -- James --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Adrian Madrid
2007-Jan-12 03:13 UTC
Re: Help: Timestamp and Userstamp just stopped working
What ended up working for me was this: class Weird < ActiveRecord::Base def self.record_timestamps; false; end end Hope it helps, AEM On 9/11/06, Jeff <cohen.jeff-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > Steven Talcott Smith wrote: > > Do not call my_model.record_timestamps = false unless you want to turn > > this behavior off system-wide. > > Interesting. What you want should certainly be possible. > > This is what I found in the documentation > (http://caboo.se/doc/classes/ActiveRecord/Timestamp.html): > > {snip} > Keep in mind that, via inheritance, you can turn off timestamps on a > per model basis by setting record_timestamps to false in the desired > models. > > class Feed < ActiveRecord::Base > self.record_timestamps = false > # ... > end > {snip} > > Try doing this and see if it helps (on your development box :-) > > I''m not sure why doing "self." would be different from what you did, > though...? > > Jeff > softiesonrails.com > > > > >-- Adrian Esteban Madrid --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---