2

我正在尝试修改一段代码:

property :email, String, :index => true, :null => false, :length => 1000

在模型定义中。我收到此错误:

ArgumentError: options :null are unknown
 from /usr/lib/ruby/gems/1.8/gems/dm-core-0.10.2/lib/dm-core/property.rb:901:in `assert_valid_options'
 from /usr/lib/ruby/gems/1.8/gems/dm-core-0.10.2/lib/dm-core/property.rb:811:in `initialize'
 from /usr/lib/ruby/gems/1.8/gems/dm-core-0.10.2/lib/dm-core/model/property.rb:51:in `new'
 from /usr/lib/ruby/gems/1.8/gems/dm-core-0.10.2/lib/dm-core/model/property.rb:51:in `property'

所以我认为我缺少一个 DataMapper 插件。

4

1 回答 1

4

I'm not aware of any DataMapper plugin that uses the :null option.

On older versions of DataMapper you'd want to use :nullable => false. The most recent DataMapper (0.10.2) provides the clearer syntax :required => true. The other option is still supported, but is deprecated.

于 2010-01-28T07:01:31.507 回答