datamapper - 查询对象属性

时间:2013-10-14 19:14:58

标签: ruby datamapper ruby-datamapper

使用带有ruby的datamapper。假设我有一个名为Post的模型:

class Post
  include DataMapper::Resource
  property :id, Serial
  property :name, String, length: 255
  property :category_ids, Object
end

Post.create(name: 'My post', category_ids: [1,2,3])

Post.all(category_ids: [1])
=> []
Post.all(category_ids: [1,2,3])
=> []

可以查询对象属性吗?

1 个答案:

答案 0 :(得分:0)

使用RangePost.all(category_ids: (1..3))