ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> rubyonrails-talk
rubyonrails-talk
[Rails] Re: Moving a record
by Wiz561@Gmail.Com other posts by this author
Aug 13 2007 2:17PM messages near this date
[Rails] Re: Moving a record | [Rails] Re: Moving a record
Ah, thank you very much...  a little tweaking of the code and it
worked.

 
MainArchive.create(Response.find(params[:id]).destroy.attributes).save



thanks for your help!!!!

mike


On Aug 13, 2:09 pm, Matthew Isleb <rails-mailing-l...@[...].net> 
wrote:
>  You could do it in one line:
> 
>  NewModel.create(OldModel.find(id).destroy.attributes)
> 
>  That provides no error checking or exception handling, of course. But
>  I'm a sucker for oneliners. :-)
> 
>  Since it is destroying the old record before creating the new one, you
>  may want to wrap it in a transaction. Or just expand it to more lines
>  and ensure that the new record is created before destroying the old.
>  However you prefer. The key is to use the attributes Hash.
> 
>  -matthew
>  --
>  Posted viahttp://www.ruby-forum.com/.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Ta
lk" group.
To post to this group, send email to rubyonrails-talk@[...].com
To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@[...].com
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Thread:
Wiz561@Gmail.Com
Matthew Isleb
Wiz561@Gmail.Com
Matthew Isleb

Privacy Policy | Email Opt-out | Feedback | Syndication
© 2004 ActiveState, a division of Sophos All rights reserved