Scaffold and form generation issue

Hi,

I am new to rails - just installed it couple of days ago (version
2.0.2). I was going through a tutorial on scaffold and it looked as
if it is extremely simple to generate the working code for a simple
table in no time. But I am facing some problem as I am unable to see
the web form properly - it does not create the form according to the
table definition in the database although it does create the action
links. So, when I click on create - it creates an empty row in the
table (the table only has id, name). The show page is empty but the
click on update displays that update was successful.

Here is how I created the application:

  1. create table categories in mysql with id(int), name(string)
  2. run rails rlapp
  3. cd rlapp
  4. ruby script\generate db:migrate categories
  5. ruby script\generate scaffold category
  6. ruby script\server
  7. open the categories page in the browser

I see that in edit.html.erb, there is a reference to form_for method.
Is the form_for method not able to generate the proper form for the
table?

Any help is really appreciated.

Below is the content of the edit file:

Editing category

<%= error_messages_for :category %>

<% form_for(@category) do |f| %>

<%= f.submit "Update" %>

<% end %>

<%= link_to ‘Show’, @category %> |
<%= link_to ‘Back’, categories_path %>

rk :

Here is how I created the application:

  1. create table categories in mysql with id(int), name(string)
  2. run rails rlapp
  3. cd rlapp
  4. ruby script\generate db:migrate categories
  5. ruby script\generate scaffold category

script/generate scaffold category name:string

  1. ruby script\server
  2. open the categories page in the browser
-- Jean-François.

Thanks! That really works.

Is this a new change to the scaffold script? Most of the tutorials
that I have seen does not mention this part. This also means that for
a decent sized table we have to name all the columns on the command
line?

On Dec 20, 10:24 am, “Jean-François Trân” [email protected]