Creating models from existing db tables

How do I automatically create model classes from an existing db
schema? this is in RoR 2.0

You don’t create models from an existing schema… you create models
that
map to existing tables :slight_smile: But I’ll stop splitting hairs.

ruby script/generate model users --skip-migration

Or just create a new class for the table manually

in app/models/user.rb

class User < ActiveRecord::Base
end

As long as your table name is pluralized and you have a primary key
column
called ‘id’ it will just work. If you don’t, you can specify the table
name
and primary key name

class User < ActiveRecord::Base
set_primary_key :person_id
set_table_name :person
end

On Tue, Feb 26, 2008 at 12:15 AM, jim starboard
[email protected]