belongs_to选项中的primary_key

在定义mode时给belongs_to加入了:primary_key选项,运行时报错,提示Unknown primary-key。去网上寻找答案,在rubyonrails的官方网站的关于rails2.3.3新特性介绍中看到有这么一段描述

:primary_key option for belongs_to for broader support of legacy schemas and those using a separate UUID primary key: belongs_to :employee, :primary_key => ‘SSN’, :foreign_key => ‘EMPID’

原来直到rails2.3.3时primary_key才被belongs_to支持,偶用的是rails2.3.2,难怪会出现Unknown primary-key错误。