0
사실은 내가 두 모델 mongomapper 개념을 사용하여 만들었으며 내가 활성 저자하지만 오류를 던지고 MongoMapper의 범위를 사용하여 데이터를 나열하지 않음 <잘난 :: 쿼리 상태 : "활성">
등의 던지는 오류를 가져 오는에 대한 범위를 언급모델 1 :
class Author
include MongoMapper::Document
key :name, String
key :status, String
validates_presence_of :name
many :books
scope :active, where(:status => 'Active')
end
모델 2 :
class Book
include MongoMapper::Document
key :title
key :author_id, ObjectId
key :status, :default => 'Active'
validates_presence_of :title
belongs_to :author
scope :active, where(:status => 'Active')
end
보기 :
Author.active.collect{|a| [a.name,a.id]}