Why were the words delete & destroy chosen for those particular operations? It always seems to me that they''re the wrong way round - ''delete'' sounds like a careful removal, whereas ''destroy'' sounds like wanton removal without regard for the aftereffects. Are there legacy reasons for the choice? Jon --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Jonathan del Strother wrote:> Why were the words delete & destroy chosen for those particular > operations? It always seems to me that they''re the wrong way round - > ''delete'' sounds like a careful removal, whereas ''destroy'' sounds like > wanton removal without regard for the aftereffects. Are there legacy > reasons for the choice?Think that "delete" comes from low level sql command "DELETE", i.e. dumb removal without any intervention from rails. Zsombor -- Company - http://primalgrasp.com Thoughts - http://deezsombor.blogspot.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 -~----------~----~----~----~------~----~------~--~---
> Why were the words delete & destroy chosen for those particular > operations? It always seems to me that they''re the wrong way round - > ''delete'' sounds like a careful removal, whereas ''destroy'' sounds like > wanton removal without regard for the aftereffects. Are there legacy > reasons for the choice? > > JonHaha, I''ve always thought the same thing :) I''m guessing only David knows for sure. -- Rick Olson http://weblog.techno-weenie.net http://mephistoblog.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 -~----------~----~----~----~------~----~------~--~---
Rick Olson wrote:>> Why were the words delete & destroy chosen for those particular >> operations? It always seems to me that they''re the wrong way round - >> ''delete'' sounds like a careful removal, whereas ''destroy'' sounds like >> wanton removal without regard for the aftereffects. Are there legacy >> reasons for the choice? >> >> Jon > > Haha, I''ve always thought the same thing :) I''m guessing only David > knows for sure. > > -- > Rick Olson > http://weblog.techno-weenie.net > http://mephistoblog.comNewbie question: What does "destroy" check for and/or fix up that might get skipped by "delete"? I struggled with this just a couple days ago and wound up apparently picking the wrong one since I couldn''t find any documentation (as usual) for the difference. Just something about "instantiates it first"; and since I didn''t particularly need to instantiate it, I chose "delete". thanks, jp -- 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 -~----------~----~----~----~------~----~------~--~---
Jonathan del Strother wrote:> It always seems to me that they''re the wrong way round - > ''delete'' sounds like a careful removal, whereas ''destroy'' sounds like > wanton removal without regard for the aftereffects.I think of it the other way around - delete sounds precise and smaller-scale, destroy sounds larger-scale and destroying something destroys it and usually things around it. That said, I''m not crazy about the term destroy -- sound too video-gamey or something. ;P Joe -- 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 8/31/06, Joe Ruby <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Jonathan del Strother wrote: > > It always seems to me that they''re the wrong way round - > > ''delete'' sounds like a careful removal, whereas ''destroy'' sounds like > > wanton removal without regard for the aftereffects. > > I think of it the other way around - delete sounds precise and > smaller-scale, destroy sounds larger-scale and destroying something > destroys it and usually things around it. That said, I''m not crazy about > the term destroy -- sound too video-gamey or something. ;P > > Joeobliterate? annihilate? massacre? decimate? too much caffeine. -- Rick Olson http://weblog.techno-weenie.net http://mephistoblog.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 -~----------~----~----~----~------~----~------~--~---
Jeff Pritchard wrote:> What does "destroy" check for and/or fix up that might get skipped by > "delete"? > > I struggled with this just a couple days ago and wound up apparently > picking the wrong one since I couldn''t find any documentation (as usual) > for the difference. Just something about "instantiates it first"; and > since I didn''t particularly need to instantiate it, I chose "delete".Every ActiveRecord object can have ''callbacks'' associated with it. These let you attach behaviour to certain points in the object''s lifecycle. For example, you could run validity checks on an object before it is created, or you could make it so that only objects that are in a certain state are allowed to be destroyed/deleted. Also, some of the built-in ActiveRecord facilities (such as :dependent => :whatever) internally make use of the callback system to do their dirty work. When you use a ''destroy'' method to delete an object or objects, ActiveRecord goes through the full process of creating the object in memory as an ActiveRecord object (AKA instantiating the object), checking all the callbacks and running them if appropriate, and deleting the row from the database. In pseudo-ruby, calling User.destroy(1) does something like this: user = User.find(1) user.run_all_before_destroy_callbacks user.execute_sql_to_delete_this_row user.run_all_after_destroy_callbacks On the other hand, calling a ''delete'' method doesn''t bother with any of this. It simply executes a SQL statement to delete the row(s) from the database, and doesn''t give any other bit of ActiveRecord a chance to get involved. So, calling User.delete(1) does something like this: User.execute_sql_to_delete_row(1) As a rule of thumb, I''d say you should always use ''destroy''. I''d only use ''delete'' if I needed to for a specific performance optimisation, and if I was absolutely sure that the class in question had no callbacks or similar related behaviour attached to it. Chris --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Rick Olson wrote:> On 8/31/06, Joe Ruby <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: >> >> Joe > > obliterate? > > annihilate? > > massacre? > > decimate?Or... # destroy, a la War Games object.GlobalThermonuclearWar Or... # AKA delete object.kill # AKA destroy object.kill(:mafia) # I''ll kill you, your children, your children''s children, ... ;P Joe -- 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 -~----------~----~----~----~------~----~------~--~---