Ah, thanks Fred,

Yes, this explains then why my other records are not being saved back
-- I get it (though, this has nothing to do with the partials --
that's a different issue. In this particular issue, I am merely
pruning the table when the user logs off). Thanks! -RVince

On Sep 7, 8:00 am, Frederick Cheung <[email protected]>
wrote:
> On Sep 7, 1:12 am, RVince <[email protected]> wrote:
>
> > Hassan,
>
> > Same problem though -- it doesn;t save them back. They just all get
> > deleted, nothing saved back. Here is my code (all the saves evaluate
> > to true, btw) and the log:
>
> As of 2.1 rails has support for partial updates - when you do a save
> only changed columns are written back. If there were no changes at all
> (as in your case) then the save is a no-op. The change tracking
> mechanism doesn't know that you've deleted a bunch of rows. There are
> methods for saying 'i've changed this attribute' (foo_will_change!)
> but there doesn't seem to be one for "I've changed all the attributes,
> just save the whole record", although it shouldn't be hard to write
> one. You could also play around with turning off partial updates
> (perhaps only for the duration of the relevant bit of code)
>
> Fred
>
>
>
> > puts "deleting all but 10 channelnotes"
> >         @cnotes  = Channelnote.find(:all,  :order => 'tstamp DESC', :limit 
> > =>
> > 10, :conditions => ["deleted=0"])
> >         Channelnote.delete_all;
> >         @cnotes.each { |cnote|
> >         s = cnote.save!
> >         puts s
> >         }
>
> > Processing AssociateSessionsController#destroy (for 127.0.0.1 at
> > 2009-09-06 20:08:09) [GET]
> >   Parameters: {"action"=>"destroy",
> > "controller"=>"associate_sessions"}
> >    [4;36;1mAssociate Columns (16.0ms) [0m    [0;1mSHOW FIELDS FROM
> > `associates` [0m
> >    [4;35;1mAssociate Load (0.0ms) [0m    [0mSELECT * FROM `associates`
> > WHERE (`associates`.`id` = '1') LIMIT 1 [0m
> >    [4;36;1mSQL (0.0ms) [0m    [0;1mBEGIN [0m
> >    [4;35;1mAssociate Update (0.0ms) [0m    [0mUPDATE `associates` SET
> > `perishable_token` = 'WF_FpyItpFvRCghqAd5W', `updated_at` =
> > '2009-09-07 00:08:09', `last_request_at` = '2009-09-07 00:08:09' WHERE
> > `id` = 1 [0m
> >    [4;36;1mSQL (0.0ms) [0m    [0;1mCOMMIT [0m
> >    [4;35;1mChannelnote Load (0.0ms) [0m    [0mSELECT * FROM
> > `channelnotes` WHERE (deleted=0) ORDER BY tstamp DESC LIMIT 10 [0m
> >    [4;36;1mChannelnote Delete all (0.0ms) [0m    [0;1mDELETE FROM
> > `channelnotes`  [0m
> >    [4;35;1mChannelnote Columns (0.0ms) [0m    [0mSHOW FIELDS FROM
> > `channelnotes` [0m
> >    [4;36;1mSQL (0.0ms) [0m    [0;1mBEGIN [0m
> >    [4;35;1mSQL (0.0ms) [0m    [0mCOMMIT [0m
> >    [4;36;1mSQL (0.0ms) [0m    [0;1mBEGIN [0m
> >    [4;35;1mSQL (0.0ms) [0m    [0mCOMMIT [0m
> >    [4;36;1mSQL (0.0ms) [0m    [0;1mBEGIN [0m
> >    [4;35;1mSQL (0.0ms) [0m    [0mCOMMIT [0m
> >    [4;36;1mSQL (0.0ms) [0m    [0;1mBEGIN [0m
> >    [4;35;1mSQL (0.0ms) [0m    [0mCOMMIT [0m
> >    [4;36;1mSQL (0.0ms) [0m    [0;1mBEGIN [0m
> >    [4;35;1mSQL (0.0ms) [0m    [0mCOMMIT [0m
> >    [4;36;1mSQL (0.0ms) [0m    [0;1mBEGIN [0m
> >    [4;35;1mSQL (0.0ms) [0m    [0mCOMMIT [0m
> >    [4;36;1mSQL (16.0ms) [0m    [0;1mBEGIN [0m
> >    [4;35;1mSQL (0.0ms) [0m    [0mCOMMIT [0m
> >    [4;36;1mSQL (0.0ms) [0m    [0;1mBEGIN [0m
> >    [4;35;1mSQL (0.0ms) [0m    [0mCOMMIT [0m
> >    [4;36;1mSQL (0.0ms) [0m    [0;1mBEGIN [0m
> >    [4;35;1mSQL (0.0ms) [0m    [0mCOMMIT [0m
> >    [4;36;1mSQL (0.0ms) [0m    [0;1mBEGIN [0m
> >    [4;35;1mSQL (0.0ms) [0m    [0mCOMMIT [0m
> > Redirected tohttp://localhost:3000/
> > Completed in 282ms (DB: 32) | 302 Found [http://localhost/logout]
--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to