建立已经存在数据库的Rails项目常用命令

创建不需要迁移文件的Model:
> ruby script/generate model Community --skip-migration

在Model中指定表名,主键
 class Community < ActiveRecord::Base
   set_table_name 'communities'
   set_primary_key :community_id
   has_many :games, :foreign_key => 'div_id'
 end

你可能感兴趣的:(java,Ruby,Rails,ActiveRecord)