Rails is very self-confident, so if you have a table named "man" and you want the corresponding model to be called by Person, you need to tell Rails to explicitly not be so smart (otherwise it is supposed to look at the plural model name for table name).
class Person < ActiveRecord::Base
set_table_name 'person'
end
If the primary key of your table is not called "id", you also need to specify this ...
set_primary_key 'person_id'
You may also need to specify a different auto-increment sequence name, depending on your database.
I don't know how I can automatically generate a model from an existing old table, but this should do you most of this way.
source
share