Fresh Mix wrote:> @row = Post.find(5)
>
> How can I save it as a new row?
>
> Post.new(@row) ?? Do I need to destroy an old id?
Did you have a look at ActiveRecord::clone
(http://api.rubyonrails.org/classes/ActiveRecord/Base.html#M002278) ?
The following might work for you :
@row = Post.find(5)
clone = @row.clone
clone.save
(NB: The associations won''t be cloned, only attributes)
--
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?hl=en
-~----------~----~----~----~------~----~------~--~---