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
<h1>New post</h1>
<% form_for(@post) do |f| %>
<%= f.error_messages %>
<p>
<%= f.submit "Create" %>
</p>
<% 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
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.
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.
If you are newbie like me and trying to follow the "Getting Started"
on http://www.railsdocumentation.org/book.html 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.
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.