Hi, Is there a way to stop the automatic timestamping. I have a model that has an updated_on field. Its great that it updates on save however there is one operation i need to do that I dont want the updated_on field to be set to the current time. Is there a way to stop this for this one operation? Thanks Iain Adams --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
YrClass.record_timestamps = false # do the deed YrClass.record_timestamps = true RSL On 8/15/07, Iain Adams <aca04iba-3Ch7lUbXYW61Qrn1Bg8BZw@public.gmane.org> wrote:> > > Hi, > > Is there a way to stop the automatic timestamping. I have a model that > has an updated_on field. Its great that it updates on save however > there is one operation i need to do that I dont want the updated_on > field to be set to the current time. Is there a way to stop this for > this one operation? > > Thanks > > Iain Adams > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I tried this but get the error NoMethodError in TopicController#show undefined method `record_timestamps='' for #<Topic:0xb6b88204> My code looks like this @topic = Topic.find params[:id] @post_pages, @posts = paginate :posts, :conditions=>["topic_id = ?", @topic.id], :per_page=>6 @topic.viewed_by @m @topic.increment ''views'' @topic.record_timestamps = false @topic.save On 15 Aug, 14:58, "Russell Norris" <r...-ftMzyaTR+bHNyFkoKTPOtdi2O/JbrIOy@public.gmane.org> wrote:> YrClass.record_timestamps = false > # do the deed > YrClass.record_timestamps = true > > RSL > > On 8/15/07, Iain Adams <aca04...-3Ch7lUbXYW61Qrn1Bg8BZw@public.gmane.org> wrote: > > > > > Hi, > > > Is there a way to stop the automatic timestamping. I have a model that > > has an updated_on field. Its great that it updates on save however > > there is one operation i need to do that I dont want the updated_on > > field to be set to the current time. Is there a way to stop this for > > this one operation? > > > Thanks > > > Iain Adams--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Notice I said YrClass in my example. ;) RSL On 8/15/07, Iain Adams <aca04iba-3Ch7lUbXYW61Qrn1Bg8BZw@public.gmane.org> wrote:> > > I tried this but get the error > > NoMethodError in TopicController#show > > undefined method `record_timestamps='' for #<Topic:0xb6b88204> > > My code looks like this > > @topic = Topic.find params[:id] > @post_pages, @posts = paginate :posts, :conditions=>["topic_id = ?", > @topic.id], :per_page=>6 > @topic.viewed_by @m > @topic.increment ''views'' > @topic.record_timestamps = false > @topic.save > > On 15 Aug, 14:58, "Russell Norris" <r...-ftMzyaTR+bHNyFkoKTPOtdi2O/JbrIOy@public.gmane.org> wrote: > > YrClass.record_timestamps = false > > # do the deed > > YrClass.record_timestamps = true > > > > RSL > > > > On 8/15/07, Iain Adams <aca04...-3Ch7lUbXYW61Qrn1Bg8BZw@public.gmane.org> wrote: > > > > > > > > > Hi, > > > > > Is there a way to stop the automatic timestamping. I have a model that > > > has an updated_on field. Its great that it updates on save however > > > there is one operation i need to do that I dont want the updated_on > > > field to be set to the current time. Is there a way to stop this for > > > this one operation? > > > > > Thanks > > > > > Iain Adams > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 also use @topic.update_without_timestamps Iain Adams wrote:> I tried this but get the error > > NoMethodError in TopicController#show > > undefined method `record_timestamps='' for #<Topic:0xb6b88204> > > My code looks like this > > @topic = Topic.find params[:id] > @post_pages, @posts = paginate :posts, :conditions=>["topic_id = ?", > @topic.id], :per_page=>6 > @topic.viewed_by @m > @topic.increment ''views'' > @topic.record_timestamps = false > @topic.save > > On 15 Aug, 14:58, "Russell Norris" <r...-ftMzyaTR+bHNyFkoKTPOtdi2O/JbrIOy@public.gmane.org> wrote: > >> YrClass.record_timestamps = false >> # do the deed >> YrClass.record_timestamps = true >> >> RSL >> >> On 8/15/07, Iain Adams <aca04...-3Ch7lUbXYW61Qrn1Bg8BZw@public.gmane.org> wrote: >> >> >> >> >>> Hi, >>> >>> Is there a way to stop the automatic timestamping. I have a model that >>> has an updated_on field. Its great that it updates on save however >>> there is one operation i need to do that I dont want the updated_on >>> field to be set to the current time. Is there a way to stop this for >>> this one operation? >>> >>> Thanks >>> >>> Iain Adams >>> > > > > >-- Sincerely, William Pratt http://www.billpratt.net billp-YbheRAKfYF4eIZ0/mPfg9Q@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
fyi, update/create_without_timestamps are private methods and should be used with caution [if at all]. a recent patch on edge removed a private method and when someone wrote a ticket about this, david said: "The method is indeed a protected method and nodoc''ed to boot. In other words, an internal, implementational detail. But sounds like people are dipping into the forbidden cookie jar regardless. [ http://dev.rubyonrails.org/ticket/9086] so I''d stick with the methodology i first mentioned. ymmv RSL On 8/15/07, William Pratt <billp-YbheRAKfYF4eIZ0/mPfg9Q@public.gmane.org> wrote:> > you can also use @topic.update_without_timestamps > > Iain Adams wrote: > > I tried this but get the error > > NoMethodError in TopicController#show > > undefined method `record_timestamps='' for #<Topic:0xb6b88204> > > My code looks like this > > @topic = Topic.find params[:id] > @post_pages, @posts = paginate :posts, :conditions=>["topic_id = ?", > @topic.id], :per_page=>6 > @topic.viewed_by @m > @topic.increment ''views'' > @topic.record_timestamps = false > @topic.save > > On 15 Aug, 14:58, "Russell Norris" <r...-ftMzyaTR+bHNyFkoKTPOtdi2O/JbrIOy@public.gmane.org> <r...-ftMzyaTR+bHNyFkoKTPOtdi2O/JbrIOy@public.gmane.org> wrote: > > YrClass.record_timestamps = false > # do the deed > YrClass.record_timestamps = true > > RSL > > On 8/15/07, Iain Adams <aca04...-3Ch7lUbXYW61Qrn1Bg8BZw@public.gmane.org> <aca04...-3Ch7lUbXYW61Qrn1Bg8BZw@public.gmane.org> wrote: > > > > Hi, > > Is there a way to stop the automatic timestamping. I have a model that > has an updated_on field. Its great that it updates on save however > there is one operation i need to do that I dont want the updated_on > field to be set to the current time. Is there a way to stop this for > this one operation? > > Thanks > > Iain Adams > > > > -- > Sincerely, > > William Pratt > > http://www.billpratt.netbillp-YbheRAKfYF4eIZ0/mPfg9Q@public.gmane.org > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
My bad. I had simply noticed it before when scanning through methods() and noticed that it did indeed work. This is great to know, thanks. Russell Norris wrote:> fyi, update/create_without_timestamps are private methods and should > be used with caution [if at all]. a recent patch on edge removed a > private method and when someone wrote a ticket about this, david said: > > "The method is indeed a protected method and nodoc''ed to boot. In > other words, an internal, implementational detail. But sounds like > people are dipping into the forbidden cookie jar regardless. > [http://dev.rubyonrails.org/ticket/9086] > > so I''d stick with the methodology i first mentioned. ymmv > > RSL > > On 8/15/07, *William Pratt* <billp-YbheRAKfYF4eIZ0/mPfg9Q@public.gmane.org > <mailto:billp-YbheRAKfYF4eIZ0/mPfg9Q@public.gmane.org>> wrote: > > you can also use @topic.update_without_timestamps > > > Iain Adams wrote: >> I tried this but get the error >> >> NoMethodError in TopicController#show >> >> undefined method `record_timestamps='' for #<Topic:0xb6b88204> >> >> My code looks like this >> >> @topic = Topic.find >> params[:id] >> @post_pages, @posts = paginate :posts, :conditions=>["topic_id = ?", >> @topic.id <http://topic.id>], :per_page=>6 >> >> @topic.viewed_by @m >> @topic.increment ''views'' >> @topic.record_timestamps = false >> @topic.save >> >> On 15 Aug, 14:58, "Russell Norris" >> <r...-ftMzyaTR+bHNyFkoKTPOtdi2O/JbrIOy@public.gmane.org> <mailto:r...-ftMzyaTR+bHNyFkoKTPOtdi2O/JbrIOy@public.gmane.org> wrote: >> >>> YrClass.record_timestamps = false >>> # do the deed >>> YrClass.record_timestamps = true >>> >>> RSL >>> >>> On 8/15/07, Iain Adams >>> <aca04...-3Ch7lUbXYW61Qrn1Bg8BZw@public.gmane.org> <mailto:aca04...-3Ch7lUbXYW61Qrn1Bg8BZw@public.gmane.org> wrote: >>> >>> >>> >>> >>>> Hi, >>>> >>>> Is there a way to stop the automatic timestamping. I have a model that >>>> has an updated_on field. Its great that it updates on save however >>>> there is one operation i need to do that I dont want the updated_on >>>> >>>> field to be set to the current time. Is there a way to stop this for >>>> this one operation? >>>> >>>> Thanks >>>> >>>> Iain Adams >>>> >> > > -- > Sincerely, > > William Pratt > > http://www.billpratt.net > <http://www.billpratt.net> > billp-YbheRAKfYF4eIZ0/mPfg9Q@public.gmane.org <mailto:billp-YbheRAKfYF4eIZ0/mPfg9Q@public.gmane.org> > > > > > > >-- Sincerely, William Pratt http://www.billpratt.net billp-YbheRAKfYF4eIZ0/mPfg9Q@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---