Newbie Problem : Scaffold does not generate html form input fields

Hi Friends,

I am newbie to Ruby on Rails and trying to follow through my first
tutorial on RoR. I am following the “Getting Started with Rails”
manual on RoR.

When I type
“$ ruby script\generate scaffold Post blog”

it gives me an error something to the effect that says invalid number
of arguments.

So I do the following.
“$ ruby script\generate scaffold Post”

That generates the scaffold code. This seems to work and generate all
files. However, it does not generate any of the fields that are
required for my model or views e.g.

app\model\post.rb has the following code
class Post < ActiveRecord::Base
end

app\views\posts\new.html.erb has the following code

New post

<% form_for(@post) do |f| %>
<%= f.error_messages %>

<%= f.submit "Create" %>

<% end %>

<%= link_to ‘Back’, posts_path %>

I am using ruby 1.8.6 (2007-09-24 patchlevel 111) [i386-mswin32] and
Rails 2.1.0

Any hints?

CAN SOMEONE GUIDE ME?

Anij

To generate some fields you need to tell the scaffold what fields you
want and what type they are. So, for example, if you wanted to create
a Post with a title and body you would do:

script/generate scaffold Post title:string body:text

If you just type in ‘script/generate scaffold’ you’ll get examples on
how to use the scaffold generator.

best.
mike

Thank you Mike,

It really helped!!!

I guess the “getting started” that I am referring to is for the older
version because now I am stuck at “start_form_tag” and can’t seem to
find that in RDoc.

I need to find the latest “getting started”. If you happen to know the
location do ping back.

and thank you for your help once again.

Regards,
anij

Michael B. wrote:

To generate some fields you need to tell the scaffold what fields you
want and what type they are. So, for example, if you wanted to create
a Post with a title and body you would do:

script/generate scaffold Post title:string body:text

If you just type in ‘script/generate scaffold’ you’ll get examples on
how to use the scaffold generator.

best.
mike

Thanks a lot, this really helped me, I couldn’t find why my “new” page
was empty.

Hi Friends,

Just in case anyone is following this post…

If you are newbie like me and trying to follow the “Getting Started”
on Create A Perfect Resume In 5 Minutes! | Online Resume Builder then Be careful!!!
because it is not yet updated for Rails 2.x. There are significant
changes in the way things are done in Rails 2.x.

Start by reading this… (hard learned lesson after wasting a perfect
rainy sunday)
http://wiki.rubyonrails.org/rails/pages/GettingStartedWithRails

Regards,
anij