Sean,
Thanks..
With the URL now enclosed by quotes, I get the following error ...hmmm.
what could i be doing wrong?
saji
# Start of Ruby code
#require 'config/environment' ! i commented this out
parent = Page.find_by_url("/articles/")
i=1
child = Page.new
child.parent = parent
child.title = "Page #{i}"
child.breadcrumb = "Page #{i}"
child.slug = "page-#{i}"
body = PagePart.new
body.content = "This is page #{i}"
child.parts = body
child.save!
# End of Ruby code
START OF ERROR MESSAGE
-------------------------------
(/usr/lib/ruby/gems/1.8/gems/radiant-0.6.1/vendor/rails/railties/lib/commands/runner.rb:45:
undefined method `each' for #<PagePart:0xb765b49c> (NoMethodError)
from
/usr/lib/ruby/gems/1.8/gems/radiant-0.6.1/vendor/rails/activerecord/lib/active_record/associations/association_collection.rb:137:in
`replace'
from
/usr/lib/ruby/gems/1.8/gems/radiant-0.6.1/vendor/rails/activerecord/lib/active_record/associations.rb:950:in
`parts='
from (eval):13
from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `eval'
from
/usr/lib/ruby/gems/1.8/gems/radiant-0.6.1/vendor/rails/railties/lib/commands/runner.rb:45
from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
`gem_original_require'
from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
`require'
from script/runner:3
END OF ERROR MESSAGE
-----------------------------------------------
* Sean Cribbs <[EMAIL PROTECTED]> [2007-05-15 22:27:52 -0700]:
> Saji,
>
> Make sure to put quotes around that URL. It should be a string, not a regex.
>
> parent = Page.find_by_url("/articles/")
>
> Sean
>
> On 5/15/07, Saji Njarackalazhikam Hameed <[EMAIL PROTECTED]> wrote:
> > Hi Daniel,
> > Thanks very much. I ran the following code (included inside a file test.rb)
> >
> > # Start of code
> > parent = Page.find_by_url(/articles/)
> >
> > i=1
> > child = Page.new
> > child.parent = parent
> > child.title = "Page #{i}"
> > child.breadcrumb = "Page #{i}"
> > child.slug = "page-#{i}"
> > body = PagePart.new
> > body.content = "This is page #{i}"
> > child.parts = body
> > child.save!
> > # End of code
> >
> > And then went to root of my application and ran:
> >
> > "script/runner -e production test.rb"
> >
> > Unfortunately I got the following error messages. Any further tips
> > would be greatly appreciated.
> >
> > saji
> >
> > /usr/lib/ruby/gems/1.8/gems/radiant-0.6.1/vendor/rails/railties/lib/commands/runner.rb:45:
> > undefined method `strip' for /articles/:Regexp (NoMethodError)
> >
> > from
> > /usr/lib/ruby/gems/1.8/gems/radiant-0.6.1/app/models/page.rb:129:in
> > `find_by_url'
> >
> > from
> > /usr/lib/ruby/gems/1.8/gems/radiant-0.6.1/app/models/page.rb:151:in
> > `find_by_url'
> >
> > from (eval):3
> > from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
> > `eval'
> > from
> > /usr/lib/ruby/gems/1.8/gems/radiant-0.6.1/vendor/rails/railties/lib/commands/runner.rb:45
> > from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
> > `gem_original_require'
> > from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
> > `require'
> > from script/runner:3
> >
> >
> > * Daniel Sheppard <[EMAIL PROTECTED]> [2007-05-16 14:24:19 +1000]:
> >
> > > require 'config/environment'
> > >
> > > parent = Page.find_by_url('/path/to/parent')
> > >
> > > 50.times do {|i|
> > > child = Page.new
> > > child.parent = parent
> > > child.title = "Page #{i}"
> > > child.breadcrumb = "Page #{i}"
> > > child.slug = "page-#{i}"
> > > body = PagePart.new
> > > body.content = "This is page #{i}"
> > > child.parts = body
> > > child.save!
> > > }
> > >
> > > > -----Original Message-----
> > > > From: [EMAIL PROTECTED]
> > > > [mailto:[EMAIL PROTECTED] On Behalf Of
> > > > Saji Njarackalazhikam Hameed
> > > > Sent: Wednesday, 16 May 2007 2:17 PM
> > > > To: [email protected]
> > > > Subject: Re: [Radiant] automated page building
> > > >
> > > > Dear Sean,
> > > > Thank you for the tips. I am comfortable with writing shell or
> > > > Ruby scripts for this task, but have no idea of the inner workings of
> > > > Radiant. I have briefly looked at the Capistrano manuals and it
> > > > is a possible tool for my purpose.
> > > > If there is an example showing how to use scripting (ruby/bash) for
> > > > this kind of job, I would be grateful to learn from it.
> > > >
> > > > Thanks,
> > > > saji
> > > >
> > > > * Sean Cribbs <[EMAIL PROTECTED]> [2007-05-15 20:55:25 -0700]:
> > > >
> > > > > You could write a Ruby script that you invoke with script/runner, or
> > > > > better yet, a Rake task. It will require some knowledge of
> > > > the inner
> > > > > workings of Radiant (at least how the models interact).
> > > > > Alternatively, if you're not comfortable with using the shell,
> > > > > Capistrano could help you automate this, especially if the
> > > > images are
> > > > > local and not from external service.
> > > > >
> > > > > Sean
> > > > >
> > > > > On 5/15/07, Saji Njarackalazhikam Hameed <[EMAIL PROTECTED]> wrote:
> > > > > > Dear All,
> > > > > >
> > > > > > I started using Radiant and appreciate much its elegant
> > > > interface. As
> > > > > > a user I find it easy to use the Radiant interface for creating
> > > > > > new pages and developing complex webpages with minimal effort.
> > > > > > I wonder if there is a way to create certain pages automatically
> > > > > > using some kind of script.
> > > > > >
> > > > > > The situation is that we have weekly updates to our
> > > > climate monitoring
> > > > > > webpage. For this, about 50 images have to be uploaded to the site
> > > > > > and the corresponding pages built every week. Wonder if
> > > > Radiant could be
> > > > > > provided instructions to do this using a script than a
> > > > person sitting
> > > > > > and typing it all in.
> > > > > >
> > > > > > Thanks for any pointers,
> > > > > > saji
> > > > > > --
> > > > > > Saji N. Hameed
> > > > > >
> > > > > > APEC Climate Center
> > > > +82 51 668 7470
> > > > > > National Pension Corporation Busan Building 12F
> > > > > > Yeonsan 2-dong, Yeonje-gu, BUSAN 611705
> > > > [EMAIL PROTECTED]
> > > > > > KOREA
> > > > > > _______________________________________________
> > > > > > Radiant mailing list
> > > > > > Post: [email protected]
> > > > > > Search: http://radiantcms.org/mailing-list/search/
> > > > > > Site: http://lists.radiantcms.org/mailman/listinfo/radiant
> > > > > >
> > > > > _______________________________________________
> > > > > Radiant mailing list
> > > > > Post: [email protected]
> > > > > Search: http://radiantcms.org/mailing-list/search/
> > > > > Site: http://lists.radiantcms.org/mailman/listinfo/radiant
> > > >
> > > > --
> > > > Saji N. Hameed
> > > >
> > > > APEC Climate Center +82 51 668
> > > > 7470
> > > > National Pension Corporation Busan Building 12F
> > > > Yeonsan 2-dong, Yeonje-gu, BUSAN 611705
> > > > [EMAIL PROTECTED]
> > > > KOREA
> > > > _______________________________________________
> > > > Radiant mailing list
> > > > Post: [email protected]
> > > > Search: http://radiantcms.org/mailing-list/search/
> > > > Site: http://lists.radiantcms.org/mailman/listinfo/radiant
> > > >
> > > _______________________________________________
> > > Radiant mailing list
> > > Post: [email protected]
> > > Search: http://radiantcms.org/mailing-list/search/
> > > Site: http://lists.radiantcms.org/mailman/listinfo/radiant
> >
> > --
> > Saji N. Hameed
> >
> > APEC Climate Center +82 51 668 7470
> > National Pension Corporation Busan Building 12F
> > Yeonsan 2-dong, Yeonje-gu, BUSAN 611705 [EMAIL PROTECTED]
> > KOREA
> > _______________________________________________
> > Radiant mailing list
> > Post: [email protected]
> > Search: http://radiantcms.org/mailing-list/search/
> > Site: http://lists.radiantcms.org/mailman/listinfo/radiant
> >
> _______________________________________________
> Radiant mailing list
> Post: [email protected]
> Search: http://radiantcms.org/mailing-list/search/
> Site: http://lists.radiantcms.org/mailman/listinfo/radiant
--
Saji N. Hameed
APEC Climate Center +82 51 668 7470
National Pension Corporation Busan Building 12F
Yeonsan 2-dong, Yeonje-gu, BUSAN 611705 [EMAIL PROTECTED]
KOREA
_______________________________________________
Radiant mailing list
Post: [email protected]
Search: http://radiantcms.org/mailing-list/search/
Site: http://lists.radiantcms.org/mailman/listinfo/radiant