Populating a table with IRB

I am new to ruby and rails so I dedided to work through the “How to
build a wiki in 20 minutes” tutorial and ran up on this snag… the
past hour of my 20 minute blog has been searching the web trying to
figure out where my syntax error is in the following:

Page.new( :name => ‘FrontPage’, :content => ‘Welcome to my front
page.’).save => true

I have combed both the rails api and the ruby api and searched here
about 50 times and still come up empty handed. I do realize this
tutorial is a little dated but I am enjoying this one a lot more than
the ones on OnLamp so I really want to work through this problem. I
appreciate your patience with the newb on this one.

[email protected] wrote:

about 50 times and still come up empty handed. I do realize this
tutorial is a little dated but I am enjoying this one a lot more than
the ones on OnLamp so I really want to work through this problem. I
appreciate your patience with the newb on this one.

That’s the tutorial here:
http://sl33p3r.free.fr/tutorials/rails/wiki/wiki-en.html

The bit that you are struggling with is shown as:

script/console
Loading development environment.

Page.new( :name => ‘FrontPage’, :content => ‘Welcome to my front
page’).save
=> true

The bit that says “=> true” after the save is IRB showing you the result
of the save - it isn’t part of the code you type in.

Hope that helps

Justin F.

audiointrigue

Page.new( :name => ‘FrontPage’, :content => ‘Welcome to my front
page.’).save => true

Use create instead of new + save

 Page.create (:name => 'FrontPage', ..)

Later you can even write code like `

book.pages<< Page.create(…)

Alain