# Programmatically creating pages

**URL:** <https://www.ruby-forum.com/t/programmatically-creating-pages/200349>\
**Category:** Radiant CMS\
**Created:** [December 9, 2010, 5:13pm UTC](https://www.ruby-forum.com/t/programmatically-creating-pages/200349 "2010-12-09T17:13:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Post date:** [December 9, 2010, 5:13pm UTC](https://www.ruby-forum.com/t/programmatically-creating-pages/200349/1 "2010-12-09T17:13:55Z")

</div>

In reference to my previous post - as I’m importing content into  
Radiant from Wordpress, how do I go about setting the created\_by to a  
user? Every time I set the value, it’s always NULL that ends up in the  
table (although updated\_by is working just fine)

Is there a hook in the code that I haven’t spotted that’s doing this?

---

<div class="post-metadata">

**Author:** ![niczm25](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/ce73a5/32.png) [@niczm25](https://www.ruby-forum.com/u/niczm25)\
**Post date:** [December 9, 2010, 6:16pm UTC](https://www.ruby-forum.com/t/programmatically-creating-pages/200349/2 "2010-12-09T18:16:44Z")

</div>

On 9 Dec 2010, at 16:13, Neil wrote:

> In reference to my previous post - as I’m importing content into Radiant from  
> Wordpress, how do I go about setting the created\_by to a user? Every time I set  
> the value, it’s always NULL that ends up in the table (although updated\_by is  
> working just fine)
> 
> Is there a hook in the code that I haven’t spotted that’s doing this?

Yes, probably. UserActionObserver sets created\_by in a before\_create  
filter that isn’t visible from the Page class itself. In the console or  
a rake task there is no current user, so it nulls any existing  
association.

Are you scripting the import? In that case you just need to set  
UserActionObserver.current\_user to a user object before you create the  
pages. If you’re assigning a different user to each page, the easiest  
way is just to do it in another operation after creation.

And re:

> The /blog part I can deal with, but the day is causing me issues. Is  
> there any way I can get Radiant to work without the day part in the  
> route?

I don’t use the archive extension - which is responsible for your urls  
here - but looking at the code, the url format will be quite hard to  
change. It’s spelt out in several places and used to support the  
day/month/year views. Perhaps an easier option would be to print the old  
and new paths as the posts are imported and use that output to create  
many specific rewrite rules rather than one general one?

best,

will
