For every table in my app there is a corresponding deleted_.* table. I would like to be able to copy a record to its corresponding deleted_.* table. How might I achieve this? If I have to have models for a deleted record, could I use some metaprogramming magic to create these models? How would I do that if so? -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/s493BIL0x0AJ. For more options, visit https://groups.google.com/groups/opt_out.
How many records are you talking about? For a few records, once in a while, you could do it in Ruby - Google using ActiveRecord outside of Rails for some more info. Why do you have deleted tables? You might consider adding a field like "Active" and filter the non active records On Monday, August 13, 2012 10:42:10 PM UTC-4, ZeroModulus wrote:> > For every table in my app there is a corresponding deleted_.* table. I > would like to be able to copy a record to its corresponding deleted_.* > table. How might I achieve this? > > If I have to have models for a deleted record, could I use some > metaprogramming magic to create these models? How would I do that if so? >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/fvDlEkHRflsJ. For more options, visit https://groups.google.com/groups/opt_out.
The number of records would vary widely. I thought of doing deleted tables because I had already thought of having an attribute to mark a record as active, but figured I would have to write an exclusion clause every time. Would there be a way to do this without having to write exclusion clauses for every query? On Monday, August 13, 2012 8:20:12 PM UTC-7, Agoofin wrote:> > How many records are you talking about? > > For a few records, once in a while, you could do it in Ruby - Google using > ActiveRecord outside of Rails for some more info. > > Why do you have deleted tables? You might consider adding a field like > "Active" and filter the non active records > > On Monday, August 13, 2012 10:42:10 PM UTC-4, ZeroModulus wrote: >> >> For every table in my app there is a corresponding deleted_.* table. I >> would like to be able to copy a record to its corresponding deleted_.* >> table. How might I achieve this? >> >> If I have to have models for a deleted record, could I use some >> metaprogramming magic to create these models? How would I do that if so? >> >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/MQdIkzqrAAgJ. For more options, visit https://groups.google.com/groups/opt_out.
Michael Pavling
2012-Aug-14 07:15 UTC
Re: Re: How can I copy records from one table to another?
On 14 Aug 2012 04:38, "ZeroModulus" <brlafreniere-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > The number of records would vary widely. > > I thought of doing deleted tables because I had already thought of havingan attribute to mark a record as active, but figured I would have to write an exclusion clause every time.> > Would there be a way to do this without having to write exclusion clausesfor every query?>Have a look at the acts_as_paranoid gem. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
Andrew Vit
2012-Aug-14 10:12 UTC
Re: Re: How can I copy records from one table to another?
acts_as_paranoid simply adds a deleted_at flag, it doesn''t move records to a separate table. Something like acts_as_archive is a better equivalent. Andrew Vit On Tuesday, August 14, 2012 12:15:01 AM UTC-7, Michael Pavling wrote:> > > On 14 Aug 2012 04:38, "ZeroModulus" <brlafr...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <javascript:>> > wrote: > > > > The number of records would vary widely. > > > > I thought of doing deleted tables because I had already thought of > having an attribute to mark a record as active, but figured I would have to > write an exclusion clause every time. > > > > Would there be a way to do this without having to write exclusion > clauses for every query? > > > > Have a look at the acts_as_paranoid gem. >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/xX8cJgUmv20J. For more options, visit https://groups.google.com/groups/opt_out.
Michael Pavling
2012-Aug-14 10:19 UTC
Re: Re: How can I copy records from one table to another?
On 14 August 2012 11:12, Andrew Vit <andrew-b/8mNwo5Adw@public.gmane.org> wrote:> acts_as_paranoid simply adds a deleted_at flag, it doesn''t move records to a > separate table.It does a *little more* than simply that...> Something like acts_as_archive is a better equivalent.The requirement to move them to another table was because the OP didn''t know how to "flag" records in the same table as deleted and have them auto-magically ignored by finders, etc. If the requirement is to archive them (which *isn''t* the same as softly deleting), along with the hassle of managing two sets of tables... then acts_as_archived could be ideal. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.