Error Trying to Use script/console to Create Pages

Hello Radiant Folk!

I’m a Radiant neophyte with a little bit of Rails experience. Thank you
so
much for making Radiant such an elegant, usable and slick CMS, I’m very
excited about using it for some upcoming projects.

I’ve long had a dream of being able to create simple,
hierarchical-navigation based sites using simple scripting or, even
better,
YAML/XML etc. to generate the framework and initial content. I’m
hopeful I
can figure out a way to do this using Radiant. I’ve been experimenting
with
some approaches using the rails console.

I first tried creating a pages_controller instance then running the new
method after setting the params property. This didn’t work due to the
use
of the request object in that method. I then
tried adapting that method so it could work as a simple page creation
function. I am running into a " undefined method `stringify_keys!’ for
“body”:String" message however.

Here’s my code:

def new_page(
title,parts,slug,breadcrumb,parent=1,behavior="",layout_id=
“1”) page = Page.
new
page.slug = slug
page.breadcrumb = breadcrumb
page.parent = Page.find_by_id(parent)
parts.each
do |part|
new_part = PagePart.new(part[
:name])
new_part.filter_id = part[
:filter_id]
new_part.content = part[:content]
page.parts << new_part

end
page.save
end

then I run

new_page(“test automatic”, [{:name=>“body”, :filter_id=>“Markdown”,
:content=>""}, {:name=>“extended”,:filter_id=>"",
:content=>""}],“test-automatic”,“test automatic”)

and get the error

NoMethodError: undefined method stringify_keys!' for "body":String from ./script/../config/../config/../vendor/rails/activerecord/lib/active_record/base.rb:1506:inattributes=’
from
./script/…/config/…/config/…/vendor/rails/activerecord/lib/active_record/base.rb:1354:in
initialize_without_callbacks' from ./script/../config/../config/../vendor/rails/activerecord/lib/active_record/callbacks.rb:236:ininitialize’
from (irb):63:in new_page' from (irb):62:innew_page’
from (irb):70
from :0

I’ve also tried creating the part_parts object using a straightforward
call
from the console (p= PagePart.new(“body”)) with the same error
resulting.

I’m on a OS X 10.4 mac with a slightly outdated install of Darwinports,
but
everything seems to be running local here, not off my Rails install.

Any thoughts on how I can batch-generate pages or fix this script?

Thanks,

Ethan

Ps. Sorry if this post is a dupe…I think I may have had some problems
sending it the first time or two.

This post was a dupe, my apologies: I didn’t see it in the archives
because
it was not under my name due to a mistake I made setting up gmail
aliasing.
Sorry for all the list spam, but any thoughts?

Thanks,

Ethan