在尝试在DataMapper中对符号使用条件时遇到麻烦:
clusters = Cluster.all(:latitude.not => nil)
此代码抛出错误:
ArgumentError - condition #<Origin::Key:0x50d05a0 @name=:latitude, @strategy=:__override__, @operator="$not", @expanded=nil, @block=
nil> of an unsupported object Origin::Key:
C:/Ruby21/lib/ruby/gems/2.1.0/gems/dm-core-1.2.1/lib/dm-core/query.rb:888:in `block in assert_valid_conditions'
C:/Ruby21/lib/ruby/gems/2.1.0/gems/dm-core-1.2.1/lib/dm-core/query.rb:853:in `each'
C:/Ruby21/lib/ruby/gems/2.1.0/gems/dm-core-1.2.1/lib/dm-core/query.rb:853:in `assert_valid_conditions'
C:/Ruby21/lib/ruby/gems/2.1.0/gems/dm-core-1.2.1/lib/dm-core/query.rb:776:in `block in assert_valid_options'
C:/Ruby21/lib/ruby/gems/2.1.0/gems/dm-core-1.2.1/lib/dm-core/query.rb:766:in `each'
C:/Ruby21/lib/ruby/gems/2.1.0/gems/dm-core-1.2.1/lib/dm-core/query.rb:766:in `assert_valid_options'
C:/Ruby21/lib/ruby/gems/2.1.0/gems/dm-core-1.2.1/lib/dm-core/query.rb:363:in `update'
C:/Ruby21/lib/ruby/gems/2.1.0/gems/dm-core-1.2.1/lib/dm-core/query.rb:386:in `merge'
C:/Ruby21/lib/ruby/gems/2.1.0/gems/dm-core-1.2.1/lib/dm-core/model.rb:767:in `scoped_query'
群集模型类:
class Cluster
include DataMapper::Resource
property :id, Serial
property :city_id, Integer
property :name, String
property :latitude, Float
property :longitude, Float
end
我正在使用的核心宝石版本:sinatra
- 1.4.6,data_mapper
- 1.2.0。
这段代码有什么问题?无法解决此错误。
答案 0 :(得分:0)