How do I add autoincrement?

Hello,

 I am attempting to learn Ruby on Rails.  I'm using Instant Rails

2.0 on a Windows computer. I really want the id number to
autoincrement, but I am not sure how to do that. The script that’s
generated after the scaffold is listed below. Any help is appreciated.

class CreateMenuitems < ActiveRecord::Migration
def self.up
create_table :menuitems do |t|
t.integer :id
t.string :category
t.text :categoryinfo
t.string :name
t.string :price
t.text :iteminfo

  t.timestamps
end

end
insert into menuitems values(NULL);
def self.down
drop_table :menuitems
end
end

On Jan 14, 2008 3:04 PM, Jeffery W. [email protected]
wrote:

 I am attempting to learn Ruby on Rails.  I'm using Instant Rails

2.0 on a Windows computer. I really want the id number to
autoincrement, but I am not sure how to do that.

t.integer :id

Remove this line. Rails will add the id field for you.


Greg D.
http://destiney.com/

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs