# Copy pages

**URL:** <https://www.ruby-forum.com/t/copy-pages/86907>\
**Category:** Radiant CMS\
**Created:** [February 26, 2007, 9:02pm UTC](https://www.ruby-forum.com/t/copy-pages/86907 "2007-02-26T21:02:54Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Todd\_McGrath](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e19b73/32.png) [@Todd\_McGrath](https://www.ruby-forum.com/u/Todd_McGrath)\
**Post date:** [February 26, 2007, 9:02pm UTC](https://www.ruby-forum.com/t/copy-pages/86907/1 "2007-02-26T21:02:54Z")

</div>

Hi,

Does anyone have a recommendation for copying existing pages from one  
parent to  
another?

I’m doing it against the database directly (sql, export, import), but  
I’m hoping  
for a more efficient way.

Todd

---

<div class="post-metadata">

**Author:** ![Todd\_McGrath](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e19b73/32.png) [@Todd\_McGrath](https://www.ruby-forum.com/u/Todd_McGrath)\
**Post date:** [February 26, 2007, 9:04pm UTC](https://www.ruby-forum.com/t/copy-pages/86907/2 "2007-02-26T21:04:55Z")

</div>

Todd,

Do you want to copy them or just move them? Moving them is fairly  
trivial with script/console.

Sean

---

<div class="post-metadata">

**Author:** ![Todd\_McGrath](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e19b73/32.png) [@Todd\_McGrath](https://www.ruby-forum.com/u/Todd_McGrath)\
**Post date:** [February 26, 2007, 9:09pm UTC](https://www.ruby-forum.com/t/copy-pages/86907/3 "2007-02-26T21:09:55Z")

</div>

Hi Sean,

I need to copy em

BTW- [radiantcms.com](http://radiantcms.com) is down?

Todd

Quoting Sean C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

---

<div class="post-metadata">

**Author:** ![Todd\_McGrath](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e19b73/32.png) [@Todd\_McGrath](https://www.ruby-forum.com/u/Todd_McGrath)\
**Post date:** [February 26, 2007, 9:27pm UTC](https://www.ruby-forum.com/t/copy-pages/86907/4 "2007-02-26T21:27:59Z")

</div>

On Feb 26, 2007, at 2:08 PM, Todd McGrath wrote:

> BTW- [radiantcms.com](http://radiantcms.com) is down?

yes, it’s not just you.

---

<div class="post-metadata">

**Author:** ![Todd\_McGrath](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e19b73/32.png) [@Todd\_McGrath](https://www.ruby-forum.com/u/Todd_McGrath)\
**Post date:** [February 26, 2007, 9:35pm UTC](https://www.ruby-forum.com/t/copy-pages/86907/5 "2007-02-26T21:35:00Z")

</div>

Todd,

Yes, I asked John about it, and TextDrive is having issues with the  
server. ([radiantcms.org](http://radiantcms.org))

There’s not a trivial way to do a deep-copy of a page, but I’ll outline  
the process for you.

1. Open script/console production (assuming you’re running in production  
mode-- I hope)
2. Use Page.find to get the original page that you intend to copy.
3. Clone the original page (original.clone).
4. Assign the parent or parent\_id of the cloned page.
5. Iterate through all the page parts of the original page, clone them,  
and add them as parts to the cloned page.
6. Save everything.

Sean

---

<div class="post-metadata">

**Author:** ![Todd\_McGrath](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e19b73/32.png) [@Todd\_McGrath](https://www.ruby-forum.com/u/Todd_McGrath)\
**Post date:** [February 27, 2007, 5:48pm UTC](https://www.ruby-forum.com/t/copy-pages/86907/6 "2007-02-27T17:48:30Z")

</div>

Todd McGrath wrote:

> BTW- [radiantcms.com](http://radiantcms.com) is down?

It’s back up now.

–  
John L.  
[http://wiseheartdesign.com](http://wiseheartdesign.com)
